Docker Compose lets you run multiple Docker containers together with a single command. Instead of starting each container manually, you define everything in a docker-compose.yml file and run docker compose up.
The problem it solves
Most apps need more than one container. A typical web app needs:
- Your app (Node.js, Python, etc.)
- A database (PostgreSQL, MySQL)
- Maybe Redis for caching
- Maybe Nginx as a reverse proxy
Without Compose, you’d run each container separately:
docker run -d --name db -e POSTGRES_PASSWORD=secret postgres
docker run -d --name redis redis
docker run -d --name app --link db --link redis -p 3000:3000 my-app
With Compose, one file, one command:
# docker-compose.yml
services:
app:
build: .
ports:
- "3000:3000"
depends_on:
- db
- redis
db:
image: postgres
environment:
POSTGRES_PASSWORD: secret
volumes:
- db-data:/var/lib/postgresql/data
redis:
image: redis
volumes:
db-data:
docker compose up # Start everything
docker compose down # Stop everything
Key features
- Networking — containers can talk to each other by service name (
db,redis). No manual linking. - Volumes — persistent data survives container restarts.
- Environment variables — configure each service.
- Dependencies —
depends_oncontrols startup order. - One command —
docker compose up -dstarts your entire stack.
When to use Docker Compose
Good fit: local development environments, small self-hosted apps, running multiple services together, CI/CD test environments.
Not ideal: production at scale (use Kubernetes), single-container apps (just use docker run).
For the full command reference, see the Docker Compose cheat sheet. See also: What is Docker? | Docker cheat sheet