Docker for self-hosting open-source AI tools: Dify, Langflow, Open WebUI, n8n and more in 2026
Why AI tools ship as containers
A self-hosted AI platform is rarely one program. Dify's default setup runs an API server, a worker, a web front end, a sandbox for code execution, an SSRF proxy, Nginx, PostgreSQL, Redis and a vector database. Each needs a specific version and configuration. A Docker Compose file describes all of them, and docker compose up -d starts the whole stack on any machine with Docker. Upgrades become pulling new images and restarting, and the same setup runs on a laptop, a $20 virtual server or a Kubernetes cluster.
Which directory projects ship Docker setups
| Project | What the Compose setup includes |
|---|---|
| Dify | API, worker, web, sandbox, PostgreSQL, Redis, Weaviate or another vector store, Nginx |
| Langflow | Langflow app with optional PostgreSQL |
| Open WebUI | One container; image variants bundle Ollama or CUDA support |
| n8n | n8n with optional PostgreSQL, plus worker containers for queue mode |
| AnythingLLM | One container with storage volume |
| LibreChat | API, MongoDB, Meilisearch, RAG API, pgvector |
Docker Engine and Desktop versions
Docker Engine is the daemon and command-line tool that run containers on Linux; it is the Moby open-source project under Apache 2.0, and version 29.9.2 is current. Docker Desktop bundles the engine in a lightweight virtual machine for Mac and Windows, with a graphical interface, Compose, Kubernetes, extensions and AI features. Desktop 4.96.2, on October 22, 2026, removed trust for certificates chained to a compromised eMudhra intermediate certificate authority. If you use Desktop, update it.
Docker Desktop pricing
| Plan | Price per user per month | Who needs it |
|---|---|---|
| Personal | Free | Individuals, education, non-commercial open source, businesses under 250 employees and $10M revenue |
| Pro | $9 annual, $11 monthly | Individual professionals wanting more build and Scout features |
| Team | $15 annual, $16 monthly | Teams needing collaboration and access controls |
| Business | $24 | Larger companies needing SSO, central management and compliance features |
The licensing rule applies only to Docker Desktop. Docker Engine on a Linux server, which is what most self-hosted AI tools run on in production, has no fee at any company size.
GPUs in containers
| Platform | How to use the GPU |
|---|---|
| Linux with NVIDIA | Install the driver and NVIDIA Container Toolkit; use --gpus all |
| Linux with AMD | Use ROCm images and pass /dev/kfd and /dev/dri devices |
| Windows | Docker Desktop with WSL 2 and a recent NVIDIA driver |
| macOS | No GPU in containers; run Ollama or Docker Model Runner natively |
In Compose, request GPUs with a deploy.resources.reservations.devices entry specifying the nvidia driver and gpu capability. Check with docker run --rm --gpus all nvidia/cuda:12.9.0-base-ubuntu24.04 nvidia-smi before debugging an AI app.
Docker's AI features
Docker has added several AI-specific tools since 2025:
| Feature | What it does |
|---|---|
| Docker Model Runner | Pulls models from Docker Hub and Hugging Face and serves them with an OpenAI-compatible API |
| MCP Catalog and Toolkit | Runs MCP servers in isolated containers and connects them to Claude, Cursor and other clients |
| Compose for agents | Declares models and MCP servers in Compose files alongside app services |
| Gordon | An AI assistant inside Docker Desktop and the CLI |
| Sandboxes | Isolated environments for running coding agents such as Claude Code safely |
Running MCP servers in containers is a sensible security step, since each server then sees only the files and network access you grant it.
Compose tips for AI stacks
- Pin image tags. Use version tags, not
latest, so an unplanned update cannot break a working setup. - Use named volumes. Databases, vector stores and uploaded files must live on volumes, or they vanish when containers are recreated.
- Keep secrets in an
.envfile with restricted permissions, never in the Compose file you commit. - Expose only the front door. Publish the web port through a reverse proxy; keep databases and Redis on the internal network with no published ports.
- Set restart policies such as
unless-stoppedso services return after a reboot. - Set memory limits for workers that load models, so one runaway process cannot take down the host.
Upgrading safely
- Read the project's release notes for breaking changes and migrations.
- Back up volumes, especially PostgreSQL. A
pg_dumpfrom the database container is usually enough. - Update the image tag, run
docker compose pull, thendocker compose up -d. - Watch logs with
docker compose logs -funtil migrations finish. - Remove old images with
docker image pruneto recover disk space.
AI images are large, often several gigabytes with CUDA libraries, so disk space runs out faster than with typical web apps.
Security
Containers isolate processes but are not a full security boundary by default. Do not run containers in privileged mode unless documented and necessary, avoid mounting the Docker socket into containers, which grants control of the host, and keep the host and Docker updated. Docker publishes ports through its own firewall rules, which can bypass UFW on Ubuntu, so a published database port may be reachable from the internet even if your firewall seems to block it; bind such ports to 127.0.0.1 or do not publish them.
Troubleshooting common AI container problems
| Symptom | Likely cause | Fix |
|---|---|---|
| App cannot reach Ollama on the host | localhost inside a container is the container itself | Use host.docker.internal, or the host's LAN IP on Linux with extra_hosts |
| Model runs very slowly | Container is using the CPU | Check GPU access with nvidia-smi inside the container |
| Disk full | Large images and build cache | docker system df, then prune unused images and cache |
| Database container restarts in a loop | Major version changed on existing data | Restore the old tag, then upgrade with a dump and restore |
Alternatives to Docker Desktop
| Tool | Platforms | Notes |
|---|---|---|
| Podman Desktop | Mac, Windows, Linux | Daemonless, rootless by default, Compose support |
| OrbStack | Mac | Fast and light; free for personal use, paid for business |
| Rancher Desktop | Mac, Windows, Linux | Free and open source, from SUSE |
| Colima | Mac, Linux | Free command-line runtime |
All run the same images, so Compose files from AI projects work with any of them, sometimes with small changes for GPU access.
Related: Kubernetes stack, PostgreSQL stack, Redis stack, Ollama stack, MCP stack, Stack index.
Frequently asked questions
Do I need Docker to self-host AI tools?
Not strictly, but it is by far the easiest way. Most AI platforms combine a web app, an API, workers, PostgreSQL, Redis and a vector database, and their Compose files start all of these together with tested versions. Installing each piece by hand is possible but slower and more error-prone.
Is Docker free?
Docker Engine on Linux is free open source. Docker Desktop is free for individuals, education, non-commercial open-source projects and businesses under 250 employees and $10 million revenue. Larger businesses need Pro at $9, Team at $15 or Business at $24 per user per month on annual billing. Alternatives such as Podman, Rancher Desktop, OrbStack and Colima can replace Desktop.
How do I give a container access to my NVIDIA GPU?
On Linux, install the NVIDIA driver and the NVIDIA Container Toolkit, then run containers with --gpus all or a Compose deploy.resources.reservations.devices block. On Windows, Docker Desktop with WSL 2 supports NVIDIA GPUs. On Macs, containers cannot use the Apple GPU, so run Ollama natively and connect containers to it.
What is Docker Model Runner?
A Docker feature that pulls and runs language models as OCI artifacts from Docker Hub and other registries, with an OpenAI-compatible API. On Macs it runs models natively on Apple silicon outside a container to use the GPU. It is an alternative to Ollama for teams already using Docker tooling.
Why did Docker Desktop 4.96.2 change certificates?
It removed trust for certificates issued by an eMudhra intermediate certificate authority that was reported compromised in October 2026. Several vendors, including the Python project, made similar changes. Update Docker Desktop to pick up the change.