Docker Compose in Production: Best Practices, Deployment & Limits

Serdar Tekin
Serdar Tekin
Co-Founder & CTO
Updated Nov 17, 202617 min read
Written for: Developers and small teams running or evaluating a production Docker Compose stack on a single cloud VM.
Docker ComposeDockerContainersProductionDevOpsCloud VM
Last reviewed:
Guide
Docker Compose in Production: Best Practices, Deployment & Limits
rafftechnologies.com/learn
On this page

Key Takeaways

Docker Compose can be production-ready when one host is an acceptable boundary. Reliability depends on reproducible config, health checks, controlled exposure, durable-state recovery, monitoring, and tested host replacement.

Run Compose in production on your own server, from $4.99 a month.

  1. 1Pick a Linux imageUbuntu, Debian and more, with your SSH key added.
  2. 2Choose a sizeFrom $4.99 a month. Resize when your app grows.
  3. 3Connect over SSHYour server is up in about 55 seconds.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

Docker Compose can be used in production when a single host is an acceptable compute, scaling, and failure boundary and the team treats the Compose stack as production infrastructure rather than a development shortcut.

The production work is not just docker compose up -d. A reliable deployment needs versioned configuration, controlled secrets, health checks, explicit networking, durable state, off-host recovery, monitoring, release discipline, and a tested way to rebuild the application on a replacement host.

Raff Technologies supports this operating model through cloud VMs for teams that want full control of Docker and the host. If the application eventually needs multi-node scheduling or less host-level operations, the next step may be an app platform or Kubernetes rather than a larger Compose file.

Docker's current documentation explicitly supports Compose for production use on a single server and recommends production-specific configuration such as different ports, environment values, restart policies, and removing development-only bind mounts.

Docker Compose in production: quick answer

QuestionProduction guidance
Can Docker Compose run production workloads?Yes, especially when one host is an acceptable boundary
Should production reuse the development file unchanged?Usually no; keep a base model and production-specific differences
Should source code be bind-mounted from the host?Usually avoid development-style code bind mounts in production
Are restart policies enough for reliability?No; they help process recovery, not host or data recovery
Do named volumes replace backups?No; a volume on one host shares that host's failure domain
Should every service expose a host port?No; expose only what must receive traffic from outside the Compose network
Does depends_on mean a dependency is ready?Not by itself; use a health check and condition: service_healthy where readiness matters
When should you move beyond Compose?When one host is no longer an acceptable availability or scheduling boundary

A good production Compose deployment is reproducible and recoverable. If a replacement VM cannot be brought up from known configuration and restored data, the stack is still dependent on the original host.

Docker Compose is a valid single-host production model

Docker Compose defines the application's services, networks, volumes, configuration, and dependencies in a machine-readable model. Docker's current documentation lists single-host production deployments as a supported Compose use case.

For a small application, a production architecture may look like this:

Text
Internet ↓ Reverse proxy / TLS endpoint ↓ Private Compose network ├── web / API ├── worker ├── scheduler └── cache Durable services ├── managed database or protected database storage ├── object storage for durable uploads └── recovery copies outside the application host

The model works well when:

  • the application fits comfortably on one VM;
  • vertical scaling is still practical;
  • short host maintenance or recovery windows are acceptable;
  • services do not need automatic placement across several nodes;
  • the team can monitor and recover the host;
  • the operational simplicity of one machine is more valuable than cluster-level automation.

The container count is not the deciding factor. Ten modest containers on one reliable host can be simpler than three services that each require independent replicas, placement, and failover.

Keep a base Compose model and a small production delta

Development and production usually need different behavior without needing two unrelated application definitions.

A useful structure is:

Text
compose.yaml + compose.production.yaml + production environment / secrets = resolved production model

Docker documents using multiple Compose files so later files override or extend the base definition. Production differences commonly include:

  • removing development bind mounts;
  • binding different host ports;
  • changing environment values;
  • setting restart behavior;
  • selecting production images;
  • changing logging options;
  • enabling or removing supporting services;
  • attaching production storage and networks.

Keep the production override as small as practical. Before deployment, inspect the fully resolved model instead of assuming file merging produced what you intended:

Bash
docker compose -f compose.yaml -f compose.production.yaml config

This is especially useful when environment interpolation, multiple files, or shared fragments affect the final configuration.

Production images should be reproducible

A production host should not become the place where application source code is edited or where undocumented build state accumulates.

Prefer an image lifecycle such as:

Text
source commit ↓ CI/build process ↓ versioned container image ↓ registry ↓ production host pulls known version

Useful production rules include:

  • use explicit image versions rather than depending only on a moving latest tag;
  • keep the Dockerfile in version control;
  • make the build repeatable from a known source revision;
  • know which image version is running before and after a release;
  • retain a rollback image while it remains compatible with the database and configuration.

An immutable image does not make the whole deployment immutable. Compose configuration, secrets, volumes, database migrations, and host-level settings also affect reproducibility.

Expose only the services that need public traffic

Compose networking and the host firewall solve different problems.

A production stack commonly exposes only the entry service:

ServiceTypical exposure
Reverse proxy / gatewayPublic 80/443
Application serviceInternal Compose network
WorkerInternal only
DatabasePrivate
CachePrivate
Metrics or admin servicePrivate or tightly restricted

Containers on the same Compose network can communicate using service names without every service publishing a host port.

Publishing database or cache ports to the public interface when no external client needs them increases attack surface without adding application value.

For wider host controls, see Cloud Security Fundamentals.

Secrets should not become ordinary application configuration

Production credentials need a deliberate ownership and distribution model.

Docker Compose supports secrets that can be explicitly granted to services and mounted into containers as files. Typical secrets include database passwords, API credentials, private keys, webhook signing secrets, third-party tokens, and TLS private material.

Whatever secret mechanism you use, define:

  1. where the source secret is stored;
  2. which service receives it;
  3. how it is rotated;
  4. how a replacement host receives it;
  5. how old credentials are revoked.

A backup of the application is incomplete if the team cannot securely restore the credentials required to start it.

Health checks should represent readiness, not just a running process

A container can be running while the application inside it is still unable to serve useful work.

Docker Compose supports healthcheck and dependency conditions. Normal dependency ordering does not mean Compose waits until a service is ready. When readiness matters, Docker documents using condition: service_healthy with a meaningful health check.

Yaml
services: app: image: example/app:1.8.2 depends_on: db: condition: service_healthy db: image: postgres:18 healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 10s timeout: 5s retries: 5 start_period: 30s

Treat this as a pattern, not a copy-paste production database design. The exact health check should match the service and should be lightweight enough to run repeatedly.

Restart policies help process recovery, not infrastructure recovery

A restart policy can bring a crashed container process back. It does not solve:

  • a failed VM;
  • corrupted persistent data;
  • a full filesystem;
  • deleted volumes;
  • a bad database migration;
  • an invalid secret;
  • a broken release;
  • unavailable external dependencies.

Production planning therefore needs separate recovery layers:

Text
Process failure -> restart policy / health monitoring Application release failure -> rollback procedure Host failure -> rebuild host + redeploy Compose stack Data loss or corruption -> backup / PITR / application-aware restore

A stack is much easier to recover when the host itself is treated as replaceable.

Persistent storage and backups are different controls

A named Docker volume can preserve data when a container is recreated. It does not make that data independent of the host.

Think in two categories:

Text
Replaceable * container image * application container * proxy container * worker container Durable * database data * customer uploads * application-generated files * secrets / configuration sources * backup archives

If durable data exists only on one VM, the host remains part of the data failure domain.

One way to reduce that risk is to keep less business state on the Compose host:

Text
Compose VM ├── web/API ├── worker └── reverse proxy ↓ Managed database ↓ Object storage

A self-hosted database inside Compose can still be valid, but then the team must own database-aware backups, restore testing, storage growth, upgrades, and corruption recovery.

For file storage decisions, see App Uploads: VM Disk vs Object Storage. For recovery planning, see RPO vs RTO for Cloud Backups.

Production releases should change the smallest necessary surface

A simple Compose release flow may be:

Text
build/test image ↓ push versioned image ↓ pull on production host ↓ run required migration ↓ recreate changed service ↓ verify health + logs + key request path

A production release plan should define:

  • the image/version being deployed;
  • how the production Compose model is rendered;
  • whether a data backup is required before a migration;
  • how database migrations are run;
  • which service or services are recreated;
  • what post-deploy verification is required;
  • what condition triggers rollback;
  • whether the previous application version remains compatible with the current database schema.

Rollback is not simply “start the old image.” A destructive or incompatible database migration can make the old application version unusable.

For deployment-strategy trade-offs, see Blue-Green vs Rolling Deployments.

Logging and monitoring must survive docker compose logs

docker compose logs is useful for immediate troubleshooting, but production observability should also cover:

  • host CPU and memory;
  • disk usage and inode pressure;
  • container restarts;
  • application error rate;
  • request latency where applicable;
  • database availability and saturation;
  • backup success/failure;
  • certificate expiry if TLS is managed locally;
  • external dependency failures;
  • storage growth.

Also define log retention. Unlimited local logs can become a disk-capacity incident on the same host that runs the application.

A production Compose host should be replaceable

A useful recovery test is simple:

If this VM disappeared, what exact inputs would we need to recreate the application elsewhere?

The answer should be a known set of artifacts:

  • host provisioning settings;
  • Docker installation/configuration;
  • Compose files;
  • image registry access;
  • environment-specific configuration;
  • secrets;
  • DNS/TLS procedure;
  • database recovery procedure;
  • persistent-file recovery procedure;
  • deployment verification steps.

A replacement-host exercise is more valuable than assuming snapshots or backups will work during the first real outage.

Docker Compose production best-practices checklist

Before relying on Compose for production, verify:

  • Compose files are version controlled.
  • Production differences are explicit and reviewed.
  • Development-only bind mounts are removed where appropriate.
  • Images use known versions.
  • Only required services publish host ports.
  • Secrets have defined ownership and rotation.
  • Important dependencies have meaningful health checks.
  • Restart behavior is defined where appropriate.
  • Durable data is identified separately from replaceable containers.
  • Backups exist outside the container lifecycle.
  • Database restores have been tested.
  • Host disk growth is monitored.
  • Application and host metrics are observable.
  • Releases include verification and rollback criteria.
  • The full stack can be recreated on a replacement host.
  • The team knows which requirement would justify moving beyond one host.

When Docker Compose stops being the right production model

RequirementSingle-host ComposeLikely next step
Several related services on one machineStrong fitStay with Compose
Predictable trafficStrong fitResize/optimize based on measurements
One-host maintenance window is acceptableStrong fitKeep recovery simple
Occasional worker separationPossibleSeparate workload onto another host if needed
Application must survive one host failingWeak fitMulti-host architecture / orchestration
Automatic workload placement across nodesNot its main modelKubernetes or another scheduler
Independent replicas across nodesWeak fitCluster-level orchestration
Many services need cluster discovery/policyWeak fitKubernetes
Team wants container deployment without managing a VMExtra host operationsConsider an app platform

Do not migrate to Kubernetes simply because the stack reached an arbitrary number of services. Move because a measured operational requirement—high availability, multi-node scheduling, independent scaling, placement, policy, or fleet management—has made the single-host boundary the problem.

For that decision, see Kubernetes vs Docker Compose for Small Teams and Container Infrastructure: Docker, K3s, and Kubernetes.

How this maps to Raff

A Raff VM is the full-control path when a team wants to operate Docker Compose directly on its own Linux host.

For current VM sizes, storage, networking, backup options, and pricing, use the live Raff pricing page rather than static numbers in this guide.

If the goal is to deploy application services without owning as much host-level operation, compare Raff Apps. If the application has genuinely moved into multi-node orchestration requirements, compare Raff Kubernetes.

The progression does not have to be Compose -> Kubernetes. It can be Compose on VM -> larger or better-operated VM -> split selected state/services -> app platform or Kubernetes only when requirements justify it.

Conclusion

Docker Compose in production is a valid choice when one host remains an acceptable deployment and failure boundary.

Production readiness comes from the operating model around Compose: reproducible configuration, known image versions, restricted exposure, secret handling, health checks, monitoring, durable-state planning, off-host recovery, controlled releases, and replacement-host procedures.

When multi-node scheduling or node-failure tolerance becomes a real requirement, move beyond the single-host model because the requirement changed—not because Compose is inherently “development only.” Docker's own documentation supports Compose as a production deployment model on a single server.

Deploy a Raff VM for Docker Compose.

14-day money-back guarantee

Deploy Your Server
Was this article helpful?
Serdar Tekin
Serdar Tekin
Co-Founder & CTO

Co-Founder & CTO at Raff, focused on cloud infrastructure, systems architecture, security, reliability, and production operations.

Run Compose in production on your own server, from $4.99 a month.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

14-day money-back guarantee

Frequently asked questions

Can Docker Compose be used in production?
Yes. Docker's current documentation supports Compose for production deployments on a single server. It is a good fit when one host is an acceptable compute, scaling, and failure boundary and the team owns monitoring, releases, security, backups, and recovery.
What are the most important Docker Compose production best practices?
Version the Compose model, keep production-specific configuration explicit, use known image versions, expose only required ports, manage secrets deliberately, add meaningful health checks, protect durable data, monitor the host and application, and test recovery on a replacement host.
Should production use a separate Docker Compose file?
A common pattern is a base compose.yaml plus a small production-specific override. Docker supports merging multiple Compose files. Review the resolved configuration with docker compose config before deployment.
Does depends_on wait until a Docker Compose service is ready?
Not automatically. Compose can start dependencies first without waiting for application readiness. When readiness matters, define a healthcheck and use a dependency condition such as service_healthy.
Do Docker volumes replace backups?
No. A named volume survives container recreation, but data stored on one VM still shares that host's failure domain. Important data needs a recovery copy and restore process appropriate to its RPO and RTO.
How should Docker Compose production releases be handled?
Deploy known image versions, render the production configuration, run required migrations deliberately, recreate only the services that changed when appropriate, verify health after deployment, and define rollback criteria before the release starts.
When should I move from Docker Compose to Kubernetes?
Move when multi-node scheduling, node-failure tolerance, automatic placement, independent replicas across nodes, or cluster-level policy has become a real recurring requirement. Do not move based only on container count.
Can I run Docker Compose on Raff?
Yes. A Raff Linux VM provides a full-control host for Docker and Docker Compose. Use the live Raff VM and pricing pages for current capacity, storage, networking, backup options, and pricing rather than relying on static article numbers.