Files
rootnode-academy/scenarios/data/docker-compose-multiservice.json
T
ced4568andClaude Sonnet 5 682ef2de47 feat(root04): author Containers & Docker
Adds all 8 ROOT 04 modules (why containers exist, images & containers, Docker CLI, container
networking, container storage, Dockerfile & image build, Docker Compose, containers →
Kubernetes) — 43 activities, using the nested Docker Engine Phase 6D built and tested. Modules
1, 2, and 8 are conceptual (no lab by design) — the honest bridge module (M8) explicitly names
what Kubernetes adds beyond what this course already taught, without re-teaching Kubernetes
itself.

Adds 5 new hands-on Docker scenarios plus 2 MCQs, all against the real nested Docker Engine:
docker-cli-basics (run/exec/inspect a real container), docker-container-networking (a genuine
"works internally, unreachable from host" port-publishing failure, diagnosed and fixed by
recreating the container with the correct `-p` flag), docker-container-storage (a real
destroy/recreate cycle proving named-volume persistence, not just described), docker-build-image
(a real Dockerfile, a real build, a real custom image run), and docker-compose-multiservice (a
real two-service Compose application with a real published port). All tested end-to-end via the
real scenario-validation API, including negative tests.

Wires rootnode-containers-assessment (2 required + 4 random-draw scenarios) using the existing
Phase 3B assessment engine.

This completes the entire ROOT_ Foundations sequence (ROOT 01-04) — see
docs/PHASE6E_ROOT_FOUNDATIONS_COMPLETION.md.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-08-26 17:08:14 -05:00

39 lines
2.8 KiB
JSON

{
"id": "docker-compose-multiservice",
"title": "Run a Real Two-Service Application With Compose",
"category": "Containers",
"isolation_type": "shared_namespace",
"difficulty": "Medium",
"type": "task",
"weight": 7,
"description": "## Run a Real Two-Service Application With Compose\n\nManually running two related containers, wiring their network, and keeping track of dependency order gets tedious fast — Compose describes the whole application in one file.\n\n**Your task**, at `/srv/compose-lab/docker-compose.yml`:\n\n1. Define a `web` service from `nginx:alpine`, publishing host port `8077` to container port `80`\n2. Define an `api` service from `alpine:3.19`, running `sh -c 'echo api-ready > /tmp/ready && sleep 3600'`\n3. Make `web` depend on `api` (`depends_on`)\n4. Bring the whole application up with `docker compose up -d`\n5. Confirm both services are actually running, and that `curl http://localhost:8077/` succeeds",
"hints": [
{
"title": "The compose file",
"body": "A `services:` block defines each container as a named service — `ports` publishes a port exactly like `docker run -p`, `depends_on` controls startup order.",
"command": "cat <<EOF > /srv/compose-lab/docker-compose.yml\nservices:\n web:\n image: nginx:alpine\n ports:\n - '8077:80'\n depends_on:\n - api\n api:\n image: alpine:3.19\n command: sh -c 'echo api-ready > /tmp/ready && sleep 3600'\nEOF"
},
{
"title": "Bringing it up",
"body": "`docker compose up -d` reads the compose file in the current directory (or use `-f` to point at one elsewhere) and starts every service defined in it.",
"command": "cd /srv/compose-lab && docker compose up -d"
}
],
"setup_commands": [
{ "command": "rm -rf /srv/compose-lab && mkdir -p /srv/compose-lab" },
{ "command": "docker pull nginx:alpine" },
{ "command": "docker pull alpine:3.19" }
],
"validation": {
"commands": [
{ "description": "the web service is running", "command": "docker compose -f /srv/compose-lab/docker-compose.yml ps --format '{{.Service}}:{{.State}}' 2>/dev/null | grep web", "expected_output": "web:running", "match": "exact" },
{ "description": "the api service is running", "command": "docker compose -f /srv/compose-lab/docker-compose.yml ps --format '{{.Service}}:{{.State}}' 2>/dev/null | grep api", "expected_output": "api:running", "match": "exact" },
{ "description": "the published port actually works", "command": "curl -sf http://localhost:8077/ -o /dev/null -w '%{http_code}'", "expected_output": "200", "match": "exact" }
]
},
"default_namespace": "default",
"teardown_commands": [
{ "command": "docker compose -f /srv/compose-lab/docker-compose.yml down 2>/dev/null; rm -rf /srv/compose-lab" }
]
}