Docker & Containers — Level by Level›Level 2 · Cheat sheet & self-check

Level 2 — Docker Compose · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

04 · Docker Compose basics

Everyday commands

docker compose up -dCreate and start everything in the background
docker compose up -d --buildRebuild images that have a build: section, then start
docker compose psServices, state and ports for this project
docker compose logs -f apiFollow one service's logs
docker compose exec db psql -U appRun a command in a running service
docker compose run --rm api python manage.py migrateOne-off command in a new container
docker compose restart apiRestart one service
docker compose downStop and remove containers and networks (volumes kept)
docker compose down -vAlso delete named volumes: data is lost

Check and debug

docker compose configShow the final merged file with variables filled in
docker compose pullPull newer images for all services
docker compose topProcesses in each service
docker compose -p shop -f compose.yaml up -dSet the project name and file explicitly

05 · Compose for real environments

Health & order

docker compose psShows (healthy) / (unhealthy) per service
docker inspect --format '{{json .State.Health}}' shop-db-1Health-check history and output
docker compose up -d --waitReturn only when services are running/healthy

Files & profiles

docker compose -f compose.yaml -f compose.prod.yaml up -dMerge a base file with an override
docker compose --profile debug up -dAlso start services in the debug profile
docker compose configSee the merged result before applying it

Keep it tidy

docker compose logs --since 10m apiRecent logs of one service
docker compose imagesImages used by the project
docker compose pull && docker compose up -dUpdate to newer image tags / digests