Inspect service status and logs
Read the Compose file
services: worker: image: busybox:1.37 pull_policy: never user: 10001:10001 network_mode: none command: - sh - -c - echo worker-ready; exec sleep 300 report: image: busybox:1.37 pull_policy: never user: 10001:10001 network_mode: none command: - sh - -c - echo report-completeThis fixture has a worker that sleeps and a report service that prints a message and exits normally. ps normally lists running containers, while ps -a includes exited ones. logs --tail 20 report restricts the displayed service and recent lines. A short-lived task can complete successfully; compare its exit status and expected work rather than treating every exit as a crash. Log text alone is not a readiness test and log retrieval depends on logging configuration. The lab uses no secrets or personal data.
Try it in a local lab
Manual lab only. Use a fresh approved disposable Linux VM with external network access blocked, local Docker Engine and modern Compose plugin. Check docker context show, docker version and docker compose version. Verify local BusyBox 1.37 image digest, native platform, inherited entrypoint, sh, sleep, wget and httpd where required, and writable /tmp for user 10001. Tags are mutable. Confirm every bm-v12 project and image tag is unused; review docker compose ls -a and project resources before mutation. For builds verify a local Buildx docker driver and preloaded base. No pulls, pushes, public ports, host mounts or real credentials. Check command/flag support locally; stop if missing. Run commands individually; unexpected failures mean stop, inspect and perform scoped cleanup. The negative probe is explicitly expected to fail. Dispose of the VM even if cleanup fails. Outputs are predictions, not recorded Docker runs. Before contacting Docker, verify the effective local endpoint including DOCKER_CONTEXT and DOCKER_HOST. Use a clean shell and reviewed fixture directory; check Compose environment overrides, .env, project labels and the resolved configuration. Explicit -f and -p select file and project, not the Engine. Run only on the approved VM; do not adopt existing resources.
Open lab-fixtures/docker-compose-fundamentals/05-observe/ in the extracted archive. Work on a disposable copy and run the commands from that directory. The examples use the modern docker compose plugin, not legacy docker-compose.
docker compose -f compose.yaml -p bm-v12-observe config --quietdocker compose -f compose.yaml -p bm-v12-observe up -d --no-build --pull neverdocker compose -f compose.yaml -p bm-v12-observe psdocker compose -f compose.yaml -p bm-v12-observe ps -adocker compose -f compose.yaml -p bm-v12-observe logs --tail 20 reportExpect worker running and report exited successfully after it has finished. Its log should contain report-complete. Exact IDs, timings and formatting vary; inspect actual state if the prediction differs. Wait only within a 15-second observation budget for report to exit. Record its exit status from ps -a (or inspect the verified report container); require code 0 and the expected marker rather than relying on log text.
Remove only the project resources you created. No volume deletion, force removal or global prune. Confirm no lab containers remain; the base image is retained.
docker compose -f compose.yaml -p bm-v12-observe downdocker compose -f compose.yaml -p bm-v12-observe ps -aCommon mistake
An absent service in ps does not prove it was never created. Check ps -a and its log before recreating anything.
Manual practice
Use the two status views and explain why report can disappear from the default view. Predict the log message for each service and identify which command limits log lines.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Inspect service status and logs — Knowledge check
Apply the Compose concept to a new scenario.
Which command includes stopped containers?
What does an exited task with status 0 usually indicate about its process?
Which is a direct application readiness check?