Docker Compose Cheatsheet - Command Reference
All essential Docker Compose commands for multi-service projects organized by Start/Stop, Logs, Config, and Network & Volume. Reference directly when managing and troubleshooting services.
Back to Containers & OrchestrationStart & Stop 5
docker compose up -dStart all services in background, omit -d for foreground logs
docker compose up -d --buildForce rebuild images before starting
docker compose stopStop services but keep containers for quick restart
docker compose downStop and remove containers and networks, add -v for volumes
docker compose restart svcRestart a specific service
Logs & Status 5
docker compose psList service status in the project
docker compose logs -f svcFollow logs for a service, omit svc for all
docker compose logs --tail=100 svcView last 100 lines for a service
docker compose topView running processes inside service containers
docker compose port svc 80View actual host port mapped to service port
Config & Build 5
docker compose configValidate and expand compose config, see variable substitution
docker compose buildBuild all service images, add --no-cache to bypass cache
docker compose pullPull all service images, do this before updating
docker compose exec svc shShell into a running service container
docker compose run --rm svc cmdRun a one-off command in a service container, --rm removes it after
Network & Volume 5
docker compose up -d --scale svc=3Horizontally scale a service to 3 instances
docker network lsList networks, compose projects create their own
docker compose down -vRemove project and clean up named volumes, data will be lost
docker volume lsList volumes, compose volume format is project_name_volume_name
docker compose config --volumesList all volumes defined in the compose file
💡 Tips
- Compose commands look for docker-compose.yml in the current directory by default; use -f for other files, -p for project name.
- down does not remove volumes by default — add -v to remove them; back up production volumes first, named volume data is irrecoverable.
- Services scaled with --scale must not use fixed host ports, or multiple instances will conflict.