Read and validate compose.yaml
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 300The worker mapping is nested under services. Each dash under command starts an item in a three-element block sequence: sh, -c and the shell script. A colon separates mapping keys and values. Use spaces, not tabs, for indentation. Quoting the user identifier as "10001:10001" is clearer and avoids parser ambiguity; the supplied scalar is read as a string by the local YAML parser. Modern Compose treats top-level version as obsolete, not a parser selector. config resolves the project model; --quiet validates without printing the normal model. Neither proves image availability or runtime success. Review only synthetic configuration because resolved values can be sensitive.
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/03-yaml/ 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-yaml config --quietdocker compose -f compose.yaml -p bm-v12-yaml config --servicesconfig --quiet is expected to finish successfully for the supplied file on a compatible plugin. config --services should list worker. These are configuration checks, not runtime tests.
Common mistake
Putting image at the same indentation as worker makes it a sibling key rather than a setting of worker. Keep service properties nested beneath the service name.
Manual practice
On a disposable copy, indent image to the same level as worker and predict the validation failure. Restore the file before continuing. No container needs to run for this task.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Read and validate compose.yaml — Knowledge check
Apply the Compose concept to a new scenario.
What determines YAML nesting?
What does config --quiet validate?
What does top-level version do in modern Compose?