Docker Compose
DefaultTool for defining and running multi-container Docker applications
Metrics
What is it
Docker Compose is a tool for defining and running multi-container Docker applications. With a simple YAML file, you can configure your application’s services, networks, and volumes, then spin up everything with a single command. It’s the de facto standard for local development and simple production deployments of containerized applications.
My Opinion
Docker Compose is the tool that made Docker actually usable. Before Compose, you were manually linking containers, managing ports, and creating networks via command-line flags. Compose brought sanity to container orchestration by letting you declare what you want, not memorize hundreds of Docker CLI arguments.
The Declarative Power
The beauty of Compose is in its simplicity. A docker-compose.yml file is readable YAML that anyone can understand:
services:
app:
build: .
ports:
- "3000:3000"
db:
image: postgres:15
This is infrastructure as code before the term existed. Your entire development stack is documented, version controlled, and reproducible. No more “it works on my machine” because everyone runs the exact same environment.
The Local Development Sweet Spot
Compose shines brightest for local development. Every developer on your team runs the same stack with docker-compose up. No more version mismatches between PostgreSQL installations, no more Redis configuration drift. The onboarding time for new developers drops from days to hours.
I use Compose for everything local: running Keycloak for authentication testing, spinning up databases for Spring applications, and orchestrating the services behind this blog.
The Production Boundary
This is where people get in trouble. Docker Compose was designed for development, not production. It lacks:
- Rolling deployments
- Auto-scaling
- Load balancing across hosts
- Service discovery
- Health-check-driven restarts
If you’re running anything mission-critical, use Kubernetes (ideally on GCP’s GKE). Compose is for development environments and simple deployments where “good enough” is acceptable.
The Watchtower Complement
For simple production use cases (home labs, personal projects), pairing Compose with Watchtower creates a lightweight deployment solution. Compose defines your stack, Watchtower keeps it updated. It’s not enterprise-grade, but it’s often good enough.
The “Docker Compose V2” Transition
Docker recently moved Compose from a standalone tool (docker-compose) to a Docker CLI plugin (docker compose). The transition was mostly smooth, but it highlighted Docker’s tendency to break backwards compatibility. The lesson: always pin your Compose file version and test upgrades carefully.
Conclusion
Docker Compose is essential for local development and simple deployments. It’s the standard because it works, it’s simple, and it’s ubiquitous. Just know its limitations—don’t try to build production-grade infrastructure with it when Kubernetes exists.