Pcornel
Containers

Docker & Compose Operations

Cheat sheet · https://pcornel.dk/topic.php?topic=6078

Back to the Topic

Answer

Docker and Compose operations: running, inspecting, updating and cleaning up containers and multi-container stacks on a single host with the docker CLI and docker compose.

Remember

Use Compose files in version control. Update with docker compose pull && docker compose up -d. Clean up carefully (docker system prune removes stopped containers and unused data).

First checks

  • docker compose ps — stack status
  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Commands

docker build -t img:tag .
docker push img:tag
docker run -d --name app -p 8080:80 img:tag
docker ps
docker logs -f app
docker inspect app
docker exec -it app sh
docker compose up -d
docker compose pull && docker compose up -d
docker compose ps
docker compose logs -f svc
docker system df
docker image prune

Verify in this order

compose file → images pulled → containers (re)created → healthchecks → logs

Where it usually breaks

Frequent problems are stale environment values, unintended anonymous volumes, dependency assumptions based only on startup order, restart loops hiding the original failure, healthchecks that test the wrong layer, and manual container changes that drift from Compose intent.

Docker & Compose Operations verification boundary matrix

BoundaryInspectHealthy interpretationDo not infer
IntentDocker CLI operational workflowIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeCompose services / Compose networks and volumesOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateEnvironment/config handlingIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeRestart policiesThe original bounded check succeeds in the same time windowProduction correctness outside this scope

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6078

Confirmation

Confirm action

Continue?