Tools: Docker Compose in Production: Is It a Good Idea?

Tools: Docker Compose in Production: Is It a Good Idea?

When Docker Compose in Production Makes Sense

The Real Limitations

Making It Production-Ready

Deployment Without Downtime

When to Move to Kubernetes "Use Kubernetes in production, Docker Compose is just for development." You've probably heard this. It's not wrong — but it's also not the whole story. For small teams, single-server setups, and projects that don't need horizontal scaling, Docker Compose in production is a completely valid choice. This very website runs on Docker Compose in production — on a single AWS t3.micro instance. Here's what I've learned. With a few additions, Docker Compose becomes quite robust: Add restart: unless-stopped to every service. It ensures containers come back up after a server reboot or crash. Zero-downtime deploys with Docker Compose require a bit of creativity: Nginx continues serving the old container while the new one starts. The gap is typically under 5 seconds. Graduate to Kubernetes when you need: multiple servers, auto-scaling, canary deployments, or if your team grows beyond 10 engineers. For everything else, Docker Compose is fast, simple, and reliable enough. Need help containerizing your application? Browse our containerization services. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

services: web: restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s retries: 3 nginx: restart: unless-stopped db: restart: unless-stopped volumes: - postgres_data:/var/lib/postgresql/data services: web: restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s retries: 3 nginx: restart: unless-stopped db: restart: unless-stopped volumes: - postgres_data:/var/lib/postgresql/data services: web: restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s retries: 3 nginx: restart: unless-stopped db: restart: unless-stopped volumes: - postgres_data:/var/lib/postgresql/data - Single server setup — your app fits on one machine (most small businesses do) - Low traffic — under ~1,000 concurrent users - Small team — 1-5 developers who don't want Kubernetes complexity - Predictable load — no need for auto-scaling - Budget constraints — one EC2 instance costs $15-30/month vs $150+ for managed Kubernetes - No auto-healing — if a container crashes, you need a restart policy to bring it back - No horizontal scaling — you can't easily add more web servers - No rolling deployments — deploys cause a brief downtime window - Single point of failure — if the server goes down, everything goes down - Sync new code to the server (rsync) - Build the new image: docker compose build web - Run migrations: docker compose exec web rails db:migrate - Reload: docker compose up -d --no-deps web