First multi-service Compose application
Read the Compose file
services: web: image: busybox:1.37 pull_policy: never user: 10001:10001 command: - sh - -c - mkdir -p /tmp/site && printf 'catalog-ready\n' > /tmp/site/index.html && exec httpd -f -p 8080 -h /tmp/site healthcheck: test: - CMD - wget - -T - '2' - -q - -O - /dev/null - http://127.0.0.1:8080/ interval: 2s timeout: 3s retries: 5 client: image: busybox:1.37 pull_policy: never user: 10001:10001 command: - sh - -c - echo client-ready; exec sleep 300networks: default: internal: trueWeb creates a tiny text file and serves it with BusyBox httpd on port 8080. Client is a separate container kept alive briefly for a probe. Both join the project default network, explicitly marked internal for the lab. Text diagram: client -> project network -> web:8080. The web listener must accept connections on its container interface; binding only to 127.0.0.1 would block the other container. Inside client, localhost means client itself, not web. A health check fetches the web document on web loopback; up --wait --wait-timeout 20 waits for running or healthy service state. The separate client probe verifies service-name resolution and an HTTP response. No host port is published; the VM must still enforce external isolation. This web server is educational, not production hardened.
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/08-multi-service/ 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-multi-service config --quietdocker compose -f compose.yaml -p bm-v12-multi-service up --wait --wait-timeout 20 --no-build --pull neverdocker compose -f compose.yaml -p bm-v12-multi-service ps -adocker compose -f compose.yaml -p bm-v12-multi-service exec -T client wget -T 3 -qO- http://web:8080/# Only after the positive probe succeeds; keep the same running client.( set -eu rc=0 docker compose -f compose.yaml -p bm-v12-multi-service exec -T client wget -T 3 -qO- http://127.0.0.1:8080/ || rc=$? test "$rc" -ne 0 # Recheck the positive path to rule out a stopped client or lost server. output=$(docker compose -f compose.yaml -p bm-v12-multi-service exec -T client wget -T 3 -qO- http://web:8080/) test "$output" = catalog-ready)Expect web healthy and client running. The client wget should return catalog-ready. A negative probe to client loopback on the same port should fail because client has no server; its exact error text is not predicted. If the readiness wait fails, inspect ps -a and web logs, then clean up. Health does not establish every application requirement. A nonzero negative-probe status alone is not proof of loopback isolation. Check that the client remained running, that the failure was a connection failure to its own loopback, and that the repeated service-name probe succeeds. The 20-second wait is a lab budget, not the complete health retry schedule.
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-multi-service downdocker compose -f compose.yaml -p bm-v12-multi-service ps -aCommon mistake
Do not publish a port just to connect two services. Use the service name and container port on their shared network. Do not replace the service name with a fixed IP that may change.
Manual practice
Draw the two containers and label the web port. Predict the result of the service-name and localhost probes. Explain why health checks, network access and published ports answer different questions. Record actual state and clean up the project.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
First multi-service Compose application — Knowledge check
Apply the Compose concept to a new scenario.
Which URL should client use to reach web?
Does inter-service traffic need a published host port?
What does the healthy state of web establish about its configured check?