Docker in production means running containers where real users depend on them, with the reliability, security and observability that a laptop never demands. The container that works perfectly on a developer machine can still fail in production when a host restarts, a disk fills up, a secret leaks into an image, or a deploy goes out with no way back. The short answer is that production Docker is less about Docker itself and more about the discipline around it: immutable images, automated deploys, health checks, resource limits and a plan for when things break.
The shift from development to production changes every assumption. On a laptop, containers are started by hand and a crash costs a developer a minute. In production, containers are started by an orchestrator, logs must be collected centrally, and a crash at three in the morning costs customers.
This guide covers the practices that close it: building images you can trust, shipping them through a registry and a pipeline, running them with the right limits and checks, and operating them day to day. For the foundations of the platform that usually runs those containers, see our guide to Kubernetes explained.
Key takeaways
- Production Docker starts with immutable, scanned images built by CI and stored in a private registry, never built by hand on a server.
- Pin image versions, set resource limits and health checks, and run containers as a non-root user with read-only filesystems where possible.
- Keep secrets out of images and pass them through a secrets manager or the orchestrator at runtime.
- Ship logs and metrics to a central system, and alert on the symptoms users feel, not only on container restarts.
- Automate deploys with rolling updates and a tested rollback, and back up any data that lives outside containers.
Build once, run everywhere
The first production rule is that the image you test is the image you ship. Build each image once in continuous integration, tag it with a unique version or commit hash, and promote that exact image through staging to production. Rebuilding at each stage invites drift, because a dependency can change between builds and the image that passed tests is no longer the image that runs.
Never use the latest tag in production. It is a moving target: a deploy that pulls latest today may get a different image from the one that pulled latest yesterday, and a rollback becomes guesswork. A versioned tag makes every deployment reproducible and every incident traceable to a specific build.
Scan images in the pipeline before they reach a registry. Docker Scout and most registries check images against vulnerability databases, and a pipeline that fails on critical findings stops a bad image before it is deployed.
Keep base images current and rebuild regularly, so security patches flow through without a special project. Our guide to container orchestration best practices covers the operational habits that keep those images running reliably.
Best for: teams moving from manual deploys to a pipeline, where a single build step with a pinned tag removes a whole class of “it worked in staging” incidents.
Registries and image storage
A registry is the source of truth for what runs in production, so treat it as infrastructure, not a convenience. Use a private registry, such as a managed service from your cloud provider or a self-hosted one, and require authentication for pulls. Public registries are fine for base images, but your own images should not be public.
Consider where the registry lives relative to your hosts. Pulling images across regions or the public internet on every deploy is slow and can fail at the worst moment, so a registry in the same region as your workloads pays for itself in deploy speed and reliability.
Choosing how to run containers
Docker Engine alone is not an orchestrator. It runs containers on one host, and that is enough for a single-server application or a small internal tool. For anything that needs high availability, you need a layer above it that schedules containers across hosts, restarts failed ones and rolls out updates.
Docker Compose is the natural step up for a single host: it defines multi-container applications in one file, with networks and volumes, and it is widely used for development and small deployments. Docker Swarm, built into Docker Engine, extends that model across several hosts with a single command to initialise a cluster. It is simple and fast to learn, but it has seen little new development in recent years, and its ecosystem is small.
Kubernetes is the default choice for most production workloads, with a vast ecosystem of tooling for networking, storage, secrets and observability. It is more complex to operate, which is why many teams use a managed service such as EKS, GKE or AKS rather than running the control plane themselves.
| Option | Hosts | Strengths | Drawbacks |
|---|---|---|---|
| Docker Engine alone | One | Simplest possible setup | No failover, no scheduling |
| Docker Compose | One | Declarative multi-container apps | Single host only |
| Docker Swarm | Several | Built into Engine, easy to learn | Small ecosystem, slow development |
| Kubernetes | Many | Autoscaling, huge ecosystem | Complex to operate |
| Managed Kubernetes | Many | Provider runs the control plane | Control plane cost, vendor ties |
Health checks, restarts and resource limits
A container that is running is not necessarily a container that is working. A process can be alive while its application is wedged, refusing connections or returning errors, and an orchestrator that only checks the process will leave it in service. Health checks close that gap: a liveness probe restarts a container that is truly stuck, and a readiness probe keeps a container out of load balancing until it can serve traffic.
Define health checks against something meaningful, such as an HTTP endpoint that exercises the application’s real dependencies, and keep the check fast and cheap. A health endpoint that runs a heavy database query on every call becomes a load problem of its own.
Set restart policies deliberately. In Compose, restart: unless-stopped keeps a container up across host reboots without restarting containers you stopped on purpose. Set resource limits on every container: a memory limit prevents one runaway process from starving its neighbours, and a CPU limit keeps a busy service from monopolising a host.
Best for: any service that has ever failed silently, where a readiness probe and a memory limit together prevent the two most common production surprises.

Secrets, configuration and networking
Secrets do not belong in images. A password, API key or certificate baked into an image layer stays in that layer forever, and anyone with registry access can extract it. Pass secrets at runtime instead, through the orchestrator’s secret store, a secrets manager, or environment variables injected by the deployment system, and rotate them on a schedule.
Separate configuration from code. Environment variables or mounted configuration files let the same image run in staging and production with different settings, which is the whole point of building once. Avoid editing files inside a running container: any change made by hand is lost at the next restart, and it is invisible to the rest of the team.
Use TLS between services where the network is shared, and keep the Docker daemon socket off the network entirely, since anyone who can reach it effectively has root on the host.
Logging and monitoring
Containers are ephemeral, so logs that live only inside a container are lost when it restarts. Send logs to a central system from the start, using the Docker logging driver or a collector such as Fluent Bit, and log in structured JSON so entries can be searched and filtered by fields rather than grepped as raw text.
Monitor the symptoms users feel: request latency, error rates and throughput, not only CPU and memory. A container can be healthy on every infrastructure metric while returning errors to every user. Alert on those user-facing signals with thresholds that give the on-call engineer time to act, and keep alerts few enough that each one is worth waking up for.
Tag every metric and log line with the service name, version and environment, so an incident can be traced to the deploy that caused it. Correlating a spike in errors with the image version that went out an hour earlier is one of the fastest ways to find a bad release.
Deploys, rollbacks and data
Automate deploys with rolling updates: replace containers a few at a time, wait for the new ones to pass their health checks, then continue. If error rates rise, stop the rollout and roll back to the previous image version, which is instant when the old image is still in the registry. A deploy that cannot be rolled back is a deploy you will regret at the worst possible time.
Test the rollback, not just the deploy. A rollback that has never been practised is a theory, and theories fail under pressure. Keep database migrations backwards compatible where you can, so the old version of the application still works against the new schema during a rollback.
Containers themselves should hold no important data. Anything that must survive a container restart belongs in a named volume or an external store, and that data needs its own backup.
A container image is replaceable; a database is not. See our guide to cloud backup best practices for a backup routine that actually restores, and our guide to common cloud infrastructure problems for the failure patterns good monitoring catches early.
Best for: teams that deploy weekly or more, where a rehearsed rollback and a tested backup turn a bad release from an outage into a footnote.
Production readiness checklist
- Images are built once in CI, tagged by version, scanned, and stored in a private registry.
- Every container has a health check, a restart policy and CPU and memory limits.
- Containers run as a non-root user, with a read-only filesystem where the application allows it.
- Secrets come from a secrets manager at runtime and never appear in an image or a repository.
- Logs and metrics flow to a central system, tagged by service, version and environment.
- Deploys roll out gradually with automatic rollback, and the rollback has been tested.
- Data lives in volumes or external stores with backups that have been restored at least once.
- Host operating systems and the Docker Engine are patched on a schedule, not when an incident forces it.
Frequently asked questions
Is Docker suitable for production?
Yes, Docker is widely used in production, but production use depends on the practices around it: immutable versioned images, an orchestrator, health checks, resource limits, centralised logging and automated deploys. Docker Engine on its own is a runtime, not a production platform.
Should I use Docker Compose in production?
Compose works well for single-host production workloads such as small internal tools, where its simplicity is a real advantage. For multi-host setups or anything that needs high availability and autoscaling, an orchestrator such as Kubernetes is the better fit.
How do I update a container without downtime?
Use a rolling update: start new containers with the updated image, wait for their health checks to pass, then stop the old ones a few at a time. An orchestrator handles this automatically, and a load balancer with readiness checks keeps traffic away from containers that are not ready.
Where should container data be stored?
Store persistent data in named volumes or external services such as a managed database or object storage, never inside the container’s writable layer. Data in a container is lost when the container is removed, and it cannot be shared or backed up reliably.
What is the biggest Docker production mistake?
Running containers as root with no resource limits and no health checks, using the latest tag, and storing secrets in images. Each of those is easy to fix, and together they account for a large share of production container incidents.







