What is Docker Compose?
Read the Compose file
services: worker: image: busybox:1.37 pull_policy: never user: 10001:10001 network_mode: none command: - sh - -c - echo project-ready; exec sleep 300The service called worker uses a local BusyBox image and prints a startup message before sleeping for five minutes. The Compose plugin reads the file, asks the Engine to create the container, and starts its main process. The image is a template; the service is the desired configuration; the container is a concrete runtime instance. Compose coordinates these objects on an Engine; it does not replace the Engine or automatically provide multi-host availability. Here networking is disabled because the worker has no communication needs.
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/01-project/ 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-project config --quietdocker compose -f compose.yaml -p bm-v12-project up -d --no-build --pull neverdocker compose -f compose.yaml -p bm-v12-project ps -adocker compose -f compose.yaml -p bm-v12-project logs --tail 20 workerExpect one running worker initially, then an exited container when its sleep finishes. The log should contain project-ready. An exited container is not necessarily an error. Observe within the five-minute worker window; check the project label and startup marker before cleanup. A successful up is not proof of readiness.
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-project downdocker compose -f compose.yaml -p bm-v12-project ps -aCommon mistake
Having compose.yaml does not start anything. The file is a description; use the Compose CLI to apply it in the intended project.
Manual practice
Identify the image, service name and project name before starting. Draw an arrow from file to service to container, and explain why the image remains after down.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
What is Docker Compose? — Knowledge check
Apply the Compose concept to a new scenario.
What is the Compose file?
What executes the container process?
What does a successful down normally leave?