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.

Containers & Orchestration·20 commands·Last updated 2026-07-21
Back to Containers & Orchestration

Start & Stop 5

docker compose up -d
Start all services in background, omit -d for foreground logs
docker compose up -d --build
Force rebuild images before starting
docker compose stop
Stop services but keep containers for quick restart
docker compose down
Stop and remove containers and networks, add -v for volumes
docker compose restart svc
Restart a specific service

Logs & Status 5

docker compose ps
List service status in the project
docker compose logs -f svc
Follow logs for a service, omit svc for all
docker compose logs --tail=100 svc
View last 100 lines for a service
docker compose top
View running processes inside service containers
docker compose port svc 80
View actual host port mapped to service port

Config & Build 5

docker compose config
Validate and expand compose config, see variable substitution
docker compose build
Build all service images, add --no-cache to bypass cache
docker compose pull
Pull all service images, do this before updating
docker compose exec svc sh
Shell into a running service container
docker compose run --rm svc cmd
Run a one-off command in a service container, --rm removes it after

Network & Volume 5

docker compose up -d --scale svc=3
Horizontally scale a service to 3 instances
docker network ls
List networks, compose projects create their own
docker compose down -v
Remove project and clean up named volumes, data will be lost
docker volume ls
List volumes, compose volume format is project_name_volume_name
docker compose config --volumes
List 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.