Compose in production and its limits
Running Compose on one server for real: a production overlay, pinned images, restarts, log rotation and deploys, and the signs you have outgrown it.
Compose for development: watch, overrides and includeStartup order: depends_on and health checks
Compose in production and its limits
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Compose on a single server is a legitimate production setup for many apps. Its limits are about the machine, not the YAML: one host is one failure domain.
- A production overlay applied with `-f` removes source mounts, pins images by tag or digest, sets restart policies, resource limits and log rotation.
- Restart policies handle crashed containers and host reboots. Nothing in Compose moves containers to another machine when the host dies.
- Compose v5.8 replaces a changed container by stopping the old one before starting the new one, so a plain redeploy has a short gap. `deploy.update_config` is a Swarm setting that `docker compose` does not use.
- The default json-file log driver never rotates logs. Set `max-size` and `max-file`, or use the `local` driver, or the disk eventually fills.
- `docker compose pull` then `docker compose up -d --wait` is a minimal deploy. Remote engines are reachable through Docker contexts.
- Move to an orchestrator when you need several hosts, automatic failover, rolling or zero-downtime updates as a platform feature, or autoscaling.
Is this allowed?
You have a working compose.yaml, one server, and an app that needs to go live. A common reflex is “Compose is for development, production needs Kubernetes”. Docker’s own production page disagrees. It calls a single server, run much like your development environment, the easiest way to deploy. Plenty of businesses run that way for years.
Think of Compose as one well-run shop. It opens on time, restocks shelves when they empty and can be managed from head office. What it cannot do is open a second branch on its own when the first one floods. The question is never “is Compose production-grade”, it is “can I live with one building”.
A production overlay
Keep the base file shared and put production differences in an overlay, as in the previous lesson:
# compose.prod.yaml
services:
web:
image: registry.example.com/web@sha256:3f1c... # or an immutable tag
volumes: !reset [] # no source bind mounts
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: "1.0"
logging:
driver: local
options:
max-size: 20m
max-file: "5"
docker compose -f compose.yaml -f compose.prod.yaml up -d --wait
Each line answers a production question.
- Which image? A tag like
latestcan move under you. A digest names exact bytes, as image names, tags and digests explains. - What if it crashes?
restart: unless-stoppedhas the engine restart the container when it exits and after a reboot, provided the Docker service starts at boot. Compose doesn’t need to run again. Details are in restart policies and health checks. - What if it leaks memory? Limits keep one service from starving the rest of the host. The
docker composeCLI appliesdeploy.resources.limitsandreservationsas container limits. More in resource limits for memory, CPU and PIDs. - What about logs? Docker’s logging page warns that by default no log rotation happens. The
json-filedriver’smax-sizedefaults to unlimited. Thelocaldriver rotates by default, 20 MB per file and five files. Set this per service as above, or once for the whole engine indaemon.json.
Secrets come from files on the server, not from the repository. See secrets at build time and run time.
Deploying a change
The minimal deploy is two commands:
docker compose -f compose.yaml -f compose.prod.yaml pull
docker compose -f compose.yaml -f compose.prod.yaml up -d --wait
up compares each service with what is running and recreates only what changed. --wait blocks until the services are running or healthy, so a script or CI job learns whether the deploy worked.
That recreate is worth understanding. I read how Compose v5.8.1 plans it in its source (pkg/compose/reconcile.go). It stops dependents first, creates the replacement under a temporary name, stops and removes the old container, renames the new one, then starts it. The old container is stopped before the new one starts, so there is a gap, a few seconds for most apps, during which requests fail.
You may find deploy.update_config with order: start-first in the Compose reference and expect it to fix that. It configures rolling updates for Swarm. I found no use of it in the docker compose source. If brief gaps matter, the usual single-host answers are a reverse proxy in front of two copies of the service that you replace one at a time, or a blue-green pair of projects started with different -p names, with the proxy switched between them. Both are scripts you own.
To deploy from your laptop or CI to the server without logging in, point the CLI at the remote engine with a Docker context, covered in Docker contexts and remote engines.
The limits, stated plainly
| Need | Compose on one host |
|---|---|
| Restart a crashed container | yes, restart policies |
| Survive a host reboot | yes, with restart policies |
| Survive the host dying | no, nothing moves containers elsewhere |
| More capacity than one machine | no |
| Rolling, zero-downtime updates | only what you script |
| Autoscaling on load | no |
| Health-based replacement | no, Docker does not restart a container for being unhealthy |
The --scale flag runs several copies on the same host. It helps with CPU-bound work, but they all share one failure domain.
When two or more “no” rows become requirements, that is the point to look at an orchestrator. Why orchestration exists explains what Kubernetes and its peers add. Compose files don’t carry over automatically, but the habits do: declared state, health checks, pinned images, limits.
Trust the file you run
Compose’s trust model page makes a point that matters more on a server than on a laptop: a Compose file has full control over how containers touch the host, including privileged mode and host mounts, and so does anything it pulls in through include or extends. Deploy only files you have reviewed, and read docker compose config output for the fully resolved version.
About the video
The embed is all of Nick Janetakis’s “Why I Like Using Docker Compose in Production”, July 2025, 19 minutes. The description says he has used Compose in production for over ten years. The chapters cover success stories, then questions: is Compose only good for development, does it scale, unpredictable traffic, how to handle deployments, and how the experience has been. It is the case for Compose from someone who runs it. It is opinion more than reference, and it says less about the limits than this lesson does. I judged it from its chapters and description, not a transcript. English was judged from the channel and its English caption track, since YouTube reports no audio language for it. Nana’s chapter in deeper is the counterpoint: the limits, and Compose versus Kubernetes.
What was run: Compose v5.8.1’s source was read to confirm how it recreates containers and that update_config is not used. Nothing was deployed, since no daemon was available. Logging defaults are from Docker’s logging driver pages, checked 2026-11-28.
Where this fits
That completes Compose. The next group asks what keeps all these containers from reaching each other and the host: container isolation and its limits.
Check yourself
Your server reboots for a kernel update. Which setting decides whether your Compose services come back?
The restart policy on each service (restart: unless-stopped or always), plus the Docker service being enabled at boot. Compose itself doesn't need to run again; the engine restarts the containers.
You set deploy.update_config.order: start-first and expected zero-downtime deploys with docker compose up -d. Why doesn't it happen?
update_config is used by Swarm, not by the docker compose CLI. Compose recreates a changed container by stopping and removing the old one before starting the replacement.
After six months the server's disk is full and docker system df shows little. What is a likely cause?
Container logs. The default json-file driver has no rotation unless max-size is set, so a chatty container's log file grows without limit.
What are two signs that an app has outgrown Compose on one server?
Any two of: it needs more than one host's capacity, it must survive a host failure without manual action, deploys must be zero-downtime as a matter of course, or it needs autoscaling with load.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.