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·25 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

FAQ 5

Q: What is the difference between docker compose up and docker compose start?
A: docker compose up creates and starts containers (add -d to run in background); docker compose start only starts existing stopped containers without recreating them.
Q: How do I rebuild images?
A: docker compose build rebuilds all service images; add --no-cache to force a full rebuild. docker compose up -d --build builds automatically before starting.
Q: How do I view Compose project logs?
A: docker compose logs -f shows all services; docker compose logs -f <service> shows only one service; add --tail=100 to limit lines.
Q: How do I start only a specific service?
A: docker compose up -d <service> starts only that service and its dependencies, leaving others stopped.
Q: How do I remove all containers and volumes?
A: docker compose down -v removes all containers and networks and cleans named volumes; data is permanently lost, use with caution in production.

💡 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.

Official References

Commands are compiled from the official docs below. Click to verify the latest usage.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Found an error? Report it

Wrong command or description? Open an issue to help us fix it.

Found an error? Report it