Docker Compose is a tool that lets you define and run multi-container Docker applications using a single configuration file. Instead of starting each container manually via the Docker CLI, you can describe all your services (like a web app, database, cache, etc.) in a docker-compose.yml
file and run everything with a single command.
Docker Compose = Project config + Multiple containers + One command to run it all
docker-compose.yml
version: '3.9'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
redis:
image: "redis:alpine"
This file:
Builds and runs a local web app container
Starts a Redis container from the official image
Automatically networks the two containers
docker-compose up # Start all services in the foreground
docker-compose up -d # Start in detached (background) mode
docker-compose down # Stop and remove containers, networks, etc.
✅ Easy setup for multi-service applications
✅ Version-controlled config (great for Git)
✅ Reproducible development environments
✅ Simple startup/shutdown of entire stacks
Local development with multiple services (e.g., web app + DB)
Integration testing with full stack
Simple deployment workflows (e.g., via CI/CD)