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]>
38 lines
2.4 KiB
JSON
38 lines
2.4 KiB
JSON
{
|
|
"id": "docker-build-image",
|
|
"title": "Write a Real Dockerfile and Build a Real Image",
|
|
"category": "Containers",
|
|
"isolation_type": "shared_namespace",
|
|
"difficulty": "Medium",
|
|
"type": "task",
|
|
"weight": 6,
|
|
"description": "## Write a Real Dockerfile and Build a Real Image\n\nA file `/srv/build-lab/greeting.txt` already exists, containing a message.\n\n**Your task:**\n\n1. Write a `Dockerfile` at `/srv/build-lab/Dockerfile` that:\n - Starts `FROM alpine:3.19`\n - Sets the working directory to `/app`\n - Copies `greeting.txt` into the image\n - Runs `cat greeting.txt` as its default command\n2. Build it, tagged `rootnode-build-lab:1`\n3. Run a container from YOUR image and confirm it prints the real content of `greeting.txt`",
|
|
"hints": [
|
|
{
|
|
"title": "The Dockerfile",
|
|
"body": "Each instruction builds one layer: FROM sets the base, WORKDIR sets the working directory for everything after it, COPY brings a file from the build context into the image, CMD sets the default command run when a container starts.",
|
|
"command": "cat <<EOF > /srv/build-lab/Dockerfile\nFROM alpine:3.19\nWORKDIR /app\nCOPY greeting.txt .\nCMD cat greeting.txt\nEOF"
|
|
},
|
|
{
|
|
"title": "Building and running",
|
|
"body": "`docker build -t <tag> <context-directory>` builds using the Dockerfile found in that directory. `docker run --rm <tag>` runs it once and cleans up automatically afterward.",
|
|
"command": "cd /srv/build-lab && docker build -t rootnode-build-lab:1 .\ndocker run --rm rootnode-build-lab:1"
|
|
}
|
|
],
|
|
"setup_commands": [
|
|
{ "command": "rm -rf /srv/build-lab && mkdir -p /srv/build-lab" },
|
|
{ "command": "echo 'Hello from my custom image' > /srv/build-lab/greeting.txt" },
|
|
{ "command": "docker pull alpine:3.19" }
|
|
],
|
|
"validation": {
|
|
"commands": [
|
|
{ "description": "the image was actually built with the expected tag", "command": "docker image inspect rootnode-build-lab:1 --format '{{.RepoTags}}' 2>/dev/null", "expected_output": "rootnode-build-lab:1", "match": "contains" },
|
|
{ "description": "a container from the student's own image produces the real file content", "command": "docker run --rm rootnode-build-lab:1 2>/dev/null", "expected_output": "Hello from my custom image", "match": "exact" }
|
|
]
|
|
},
|
|
"default_namespace": "default",
|
|
"teardown_commands": [
|
|
{ "command": "docker rmi rootnode-build-lab:1 2>/dev/null; rm -rf /srv/build-lab" }
|
|
]
|
|
}
|