Level 2 — Docker Compose · wrap-up
Cheat sheet & self-check
Every command from this section on one page.
Everyday commands
docker compose up -d | Create and start everything in the background |
docker compose up -d --build | Rebuild images that have a build: section, then start |
docker compose ps | Services, state and ports for this project |
docker compose logs -f api | Follow one service's logs |
docker compose exec db psql -U app | Run a command in a running service |
docker compose run --rm api python manage.py migrate | One-off command in a new container |
docker compose restart api | Restart one service |
docker compose down | Stop and remove containers and networks (volumes kept) |
docker compose down -v | Also delete named volumes: data is lost |
Check and debug
docker compose config | Show the final merged file with variables filled in |
docker compose pull | Pull newer images for all services |
docker compose top | Processes in each service |
docker compose -p shop -f compose.yaml up -d | Set the project name and file explicitly |
Health & order
docker compose ps | Shows (healthy) / (unhealthy) per service |
docker inspect --format '{{json .State.Health}}' shop-db-1 | Health-check history and output |
docker compose up -d --wait | Return only when services are running/healthy |
Files & profiles
docker compose -f compose.yaml -f compose.prod.yaml up -d | Merge a base file with an override |
docker compose --profile debug up -d | Also start services in the debug profile |
docker compose config | See the merged result before applying it |
Keep it tidy
docker compose logs --since 10m api | Recent logs of one service |
docker compose images | Images used by the project |
docker compose pull && docker compose up -d | Update to newer image tags / digests |