Docker & Compose Operations
Cheat sheet · https://pcornel.dk/topic.php?topic=6078
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 statusdocker ps -a— containers and exit codesdocker logs <c>— container outputdocker inspect <c>— config, mounts, network, state
Commands
docker build -t img:tag .docker push img:tagdocker run -d --name app -p 8080:80 img:tagdocker psdocker logs -f appdocker inspect appdocker exec -it app shdocker compose up -ddocker compose pull && docker compose up -ddocker compose psdocker compose logs -f svcdocker system dfdocker 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
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | Docker CLI operational workflow | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Compose services / Compose networks and volumes | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Environment/config handling | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | Restart policies | The original bounded check succeeds in the same time window | Production 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