Docker Compose is a tool for defining and running multi-container Docker applications using a single YAML configuration file. Originally written in Python (v1) and now rewritten in Go (v2/v5), it simplifies orchestrating complex applications by managing service definitions, networking, volumes, and dependencies through declarative configuration rather than imperative commands. Docker Compose is essential for local development environments, integration testing, and single-host production deployments where full orchestration platforms like Kubernetes would be overkill. One critical insight: while Compose handles service startup order through depends_on, it does not wait for services to be ready—only for containers to start. This is why health checks and service_healthy conditions are crucial for reliable multi-container orchestration. As of 2025–2026, Compose v5 ("Mont Blanc") is the current major version, the legacy docker-compose v1 binary was fully removed in April 2025, and new features include AI model support via the models: element, OCI artifact distribution, and Bake-powered builds.
What This Cheat Sheet Covers
This topic spans 26 focused tables and 201 indexed concepts, 139 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Essential CLI Commands
The core docker compose subcommands control every phase of the container lifecycle — from first boot to teardown. Knowing the difference between up, run, start, and restart (and their flags) prevents most day-to-day operational mistakes.
| Command | Example | Description | |
|---|---|---|---|
docker compose up -d | • Builds, (re)creates, starts, and attaches to containers • -d runs detached (background mode), aggregates logs by default when run in foreground | ||
docker compose down -v | • Stops and removes containers, networks, and optionally volumes ( -v) and images (--rmi)• cleans up the entire stack | ||
docker compose ps --all | • Lists containers for services • --all includes stopped containers, shows status, ports, and health | ||
docker compose logs -f web--tail=100 | • Views output from containers • -f follows log output in real-time, --tail limits lines, --timestamps adds timestamps | ||
docker compose exec web sh | • Runs command in a running service container • -it for interactive shell, -u sets user, does not create new containers | ||
docker compose run --rm test npm test | • Starts a new container for one-off commands or scripts • --rm removes container after run, does not start dependencies by default | ||
docker compose build --no-cache | • Builds or rebuilds service images • --no-cache ignores build cache, --pull always attempts to pull newer base images | ||
docker compose pull | • Pulls service images from registry • useful before up to ensure latest images, --ignore-pull-failures continues on error | ||
docker compose push | • Pushes service images to their configured registry • requires images to have image: name with registry prefix | ||
docker compose publish username/myapp:v1.0 | • Packages and publishes the entire Compose application as an OCI artifact to a container registry • run with docker compose -f oci://registry/app:tag up; requires Compose 2.34+ | ||
docker compose restart web | • Restarts running and stopped services • does not pick up configuration changes—use up for that | ||
docker compose stop | • Stops running containers without removing them • preserves container state for later start | ||
docker compose start | • Starts existing stopped containers • does not create new containers or apply config changes | ||
docker compose config --environment | • Validates and resolves the Compose file • shows interpolated variables, merged override files, and final configuration | ||
docker compose watch | • Monitors local file changes and syncs or rebuilds automatically • uses develop.watch configuration for hot reload workflows | ||
docker compose pause db | • Pauses running containers using cgroup freezer • suspends all processes without stopping container, preserves connections | ||
docker compose unpause db | • Resumes paused containers • restores all suspended processes to running state |