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