Skip to the levels
ROOTSPIRE
DiscsFor teachers
▶ Play freeLibrary 16 discsDiscsFor teachersLog in

Every level, in the open

Docker & Containers

13 worlds · 114 levels · 13 bosses

SOLUTION HIDDENTeachers see answer keys in the classroom.

▶ Play this discAll discs
All discsLinux: Zero to RootBash ScriptingGitDatabasesPython for OpsLinux Sysadmin ProNetworkingObservabilityCloud & IaCDocker & ContainersCTF ArenaSOC FieldWindows for Linux peopleKubernetesAnsibleThe Guildhall: First Week

Build containers from scratch (chroot, namespaces, cgroups, layers, your own mini-docker), then ship with the real thing: Dockerfiles, ports, volumes, day-2 ops. Honest note: docker here is podman, a real engine with the same commands; no internet, so images come from local tarballs.

Guided levels show the command first. Alone levels give the goal only. Bosses and exams are timed.

Jump to a world

World 1 The JailWorld 2 Hall of MasksWorld 3 The ScalesWorld 4 The Layer CakeWorld 5 The Cargo BayWorld 6 The DockWorld 7 The RecipeWorld 8 The KitchenWorld 9 The WiringWorld 10 The PortsWorld 11 The HoldsWorld 12 The ShiftWorld 13 The Night Watch

World 1The Jail

7 levels

A container starts as a folder that a process believes is the whole world: chroot, libraries, busybox and /proc.

  1. 1

    Level 1: A room with no doors

    GuidedEasy

    Objective: Enter the jail ~/jail/rootfs with chroot and, from inside, create the file /hello.

    A container is a process that sees a different /: a whole root filesystem living in one folder. sudo chroot DIR CMD runs CMD with DIR as its /.

    Commands taughtrootfschroot

    ▶ Play: A room with no doorsSOLUTION HIDDEN15 XP
  2. 2

    Level 2: Bring your own shell

    GuidedEasy

    Objective: Make the empty jail ~/jail/empty work (ldd shows what its shell needs), so sudo chroot ~/jail/empty /bin/sh starts a shell.

    Inside a jail, a program finds nothing from the outside world, not even its shared libraries. ldd PROGRAM lists the libraries it needs, and they must sit at the same paths inside.

    Commands taughtldd

    ▶ Play: Bring your own shellSOLUTION HIDDEN20 XP
  3. 3

    Level 3: A hundred tools in one

    GuidedEasy

    Objective: Give the jail ~/jail/tools its commands with busybox, so ls works inside it.

    busybox is one program that acts as ls, cat, ps and 300 more, depending on the name you call it by. busybox --install -s creates all those names as links.

    Commands taughtbusybox

    ▶ Play: A hundred tools in oneSOLUTION HIDDEN20 XP
  4. 4

    Level 4: Bash behind bars

    AloneMedium

    Objective: Make bash run inside ~/jail/bashroom, so hidden prints hi.

    Bigger programs need several libraries, and ldd gives each one's full path. Copy every one, keeping its path (cp --parents helps).

    ▶ Play: Bash behind barsSOLUTION HIDDEN25 XP
  5. 5

    Level 5: The window in the wall

    AloneMedium

    Objective: Make ps work inside ~/jail/rootfs by mounting proc on its /proc.

    ps reads /proc, and a jail's /proc is empty until you mount it: mount -t proc proc DIR/proc. Then look closely: a chroot hides files, not processes.

    Commands taughtproc-mount

    ▶ Play: The window in the wallSOLUTION HIDDEN25 XP
  6. 6

    Level 6: A curtain, not a wall

    GuidedEasy

    Objective: From inside the jail ~/jail/rootfs (proc is already mounted), read the warden's code in the host's /root/warden.txt and tell Kern: kern <code>.

    /proc/PID/root is a door into the / of process PID, and PID 1 started outside the jail: from inside, /proc/1/root leads back to the host's /. That's why chroot alone is not a container; real runtimes use pivot_root inside namespaces (Hall of Masks).

    Commands taughtchroot-escape

    ▶ Play: A curtain, not a wallSOLUTION HIDDEN25 XP
  7. 7

    Level 7: Build a cell

    Boss⏱ TimedHard

    Objective: Turn the empty ~/jail/cell into a jail where /bin/sh and ls work, /etc/hostname says cell, and proc is mounted.

    No help this time: a jail from an empty folder.

    ▶ Play: Build a cellSOLUTION HIDDEN60 XP

World 2Hall of Masks

12 levels

Namespaces give a process its own hostname, process list, mounts, network and even its own root user.

  1. 8

    Level 8: Everyone wears masks

    GuidedEasy

    Objective: Find the number of your shell's uts namespace and tell Kern: kern <number>.

    A namespace is a private view of one kind of thing (uts = hostname, pid = process list, mnt = mounts, net = network, user = user ids), and every process sits in one of each. hidden shows your shell's; two processes share a namespace when the numbers in brackets match.

    Commands taughtnamespaces

    ▶ Play: Everyone wears masksSOLUTION HIDDEN15 XP
  2. 9

    Level 9: A new name tag

    GuidedEasy

    Objective: Start sleep 7101 with unshare in its own UTS namespace, hostname mask, without renaming rootspire.

    unshare starts a command in new namespaces; -u gives it a new UTS namespace, so its hostname changes only there. That's docker run --hostname.

    Commands taughtunshare

    ▶ Play: A new name tagSOLUTION HIDDEN20 XP
  3. 10

    Level 10: Process number one

    GuidedEasy

    Objective: Run sleep 7102 in a new PID namespace where it is PID 1.

    A new PID namespace numbers processes from 1, and its processes can't see anything outside. unshare -p -f --mount-proc forks the command as PID 1 and gives it a matching /proc.

    Commands taughtpid-namespace

    ▶ Play: Process number oneSOLUTION HIDDEN20 XP
  4. 11

    Level 11: Private mounts

    GuidedEasy

    Objective: Run sleep 7103 in its own mount namespace with a tmpfs mounted on /mnt that the host can't see.

    unshare -m gives a process its own copy of the mount table: what it mounts, the host never sees. That's how docker run -v and the container's own / stay private.

    Commands taughtmount-namespace

    ▶ Play: Private mountsSOLUTION HIDDEN20 XP
  5. 12

    Level 12: A real wall

    GuidedEasy

    Objective: Run sleep 7108 in its own mount namespace with ~/masks/rootfs as its / (pivot_root) and the old / unmounted.

    pivot_root makes a folder the new / of a private mount namespace and moves the old / onto a subfolder, which you then unmount: the host's files are gone from that world, not just hidden. The new root must be a mount point, so bind-mount the folder onto itself first.

    Commands taughtpivot-root

    ▶ Play: A real wallSOLUTION HIDDEN25 XP
  6. 13

    Level 13: Visitor's tour

    GuidedEasy

    Objective: A container is running sleep 7110. Visit its UTS namespace, read its hostname, and tell Kern.

    Four moves you'll need next, one at a time: unshare -r (a user namespace where you are root), unshare -n (a network namespace with nothing in it), ip netns (names for those), and nsenter (visit a running container).

    Commands taughtnetns

    ▶ Play: Visitor's tourSOLUTION HIDDEN30 XP
  7. 14

    Level 14: Root without sudo

    AloneMedium

    Objective: Without sudo, write what id -u prints inside a user namespace into ~/masks/fakeroot.txt.

    A user namespace maps your user to root inside it: unshare -r makes you uid 0 there, with no sudo. It's root only over your own things: that's how rootless containers work.

    Commands taughtuser-namespace

    ▶ Play: Root without sudoSOLUTION HIDDEN25 XP
  8. 15

    Level 15: Who's who

    GuidedEasy

    Objective: Without sudo, start sleep 7105 in a new user namespace (unshare -U … &), then write its uid_map so uid 0 inside is you (uid 1000) outside.

    unshare -r is two steps: unshare -U makes a user namespace where nobody is mapped yet, then a line 'INSIDE OUTSIDE COUNT' in /proc/PID/uid_map maps ids ('0 1000 1': uid 0 inside is you outside). You may write that one line for your own uid without sudo.

    Commands taughtuid-map

    ▶ Play: Who's whoSOLUTION HIDDEN25 XP
  9. 16

    Level 16: Into the vault

    AloneMedium

    Objective: A container is running sleep 7104: enter its mount namespace and tell Kern the code in its /mnt/code.txt.

    nsenter -t PID joins the namespaces of a running process (-m mounts, -u uts, -p pid, -n net). It's what docker exec does.

    Commands taughtnsenter

    ▶ Play: Into the vaultSOLUTION HIDDEN30 XP
  10. 17

    Level 17: A network of one

    AloneMedium

    Objective: Create the network namespace pod and bring its lo interface up.

    ip netns add NAME creates a network namespace: an empty network stack with just a lo that's down. ip netns exec NAME CMD runs inside it, like docker run --network none.

    Commands taughtnetns

    ▶ Play: A network of oneSOLUTION HIDDEN25 XP
  11. 18

    Level 18: The inspector

    Alone⏱ TimedHard

    Objective: Find the hostname of the container running sleep 7107 and tell Kern.

    Quick: a container is up and nobody knows its name.

    ▶ Play: The inspectorSOLUTION HIDDEN35 XP
  12. 19

    Level 19: The masquerade

    Boss⏱ TimedHard

    Objective: Without sudo, run sleep 7109 as PID 1 of its own user, PID, mount, UTS and network namespaces, with hostname ghost.

    Every mask at once, and no sudo.

    ▶ Play: The masqueradeSOLUTION HIDDEN70 XP

World 3The Scales

10 levels

Control groups weigh what each container may use: processes, memory and CPU, all through plain files.

  1. 20

    Level 20: The weighing room

    GuidedEasy

    Objective: Create the cgroup box.

    Control groups (cgroups) put processes in groups and limit what a group may use. In cgroup v2 a group is just a folder under /sys/fs/cgroup: mkdir creates it and the kernel fills it with knob files.

    Commands taughtcgroups

    ▶ Play: The weighing roomSOLUTION HIDDEN15 XP
  2. 21

    Level 21: Into the box

    GuidedEasy

    Objective: Move the running sleep 7201 into the cgroup box.

    A process joins a group when you write its PID into the group's cgroup.procs, and /proc/PID/cgroup shows where it lives. Root owns those files, so write with echo PID | sudo tee FILE.

    Commands taughtcgroup-procs

    ▶ Play: Into the boxSOLUTION HIDDEN20 XP
  3. 22

    Level 22: Fork bomb shield

    GuidedEasy

    Objective: Limit the cgroup box to at most 5 processes.

    pids.max caps how many processes a group may have; past it, fork fails. A container with a pid limit survives a fork bomb (docker run --pids-limit).

    Commands taughtpids-max

    ▶ Play: Fork bomb shieldSOLUTION HIDDEN20 XP
  4. 23

    Level 23: Boxes in boxes

    GuidedEasy

    Objective: Create the cgroup yard with a child yard/web that has its own pids.max and memory.max knobs.

    mkdir inside a group makes a child group, but a child only gets the knobs (memory.max, pids.max…) of controllers listed in its parent's cgroup.subtree_control: echo '+memory +pids' into it. Docker nests like this: one parent group, one child per container.

    Commands taughtsubtree-control

    ▶ Play: Boxes in boxesSOLUTION HIDDEN20 XP
  5. 24

    Level 24: Reading the gauges

    GuidedEasy

    Objective: Of box and tenant, one holds a lot of memory and the other has burned CPU: tell Kern which is which with kern <memory hog> <cpu hog>.

    Groups don't only limit, they measure. memory.current is how many bytes the group uses right now, and the usage_usec line of cpu.stat is the CPU time it has burned, in microseconds. docker stats (and kubectl top) read exactly these files.

    Commands taughtcgroup-stats

    ▶ Play: Reading the gaugesSOLUTION HIDDEN20 XP
  6. 25

    Level 25: Memory diet

    AloneMedium

    Objective: Cap the cgroup lab at 16 MiB of memory.

    memory.max is the most a group may use; past it the kernel reclaims, then kills a process (the OOM killer). It accepts suffixes like 16M (docker run --memory 16m).

    Commands taughtmemory-max

    ▶ Play: Memory dietSOLUTION HIDDEN25 XP
  7. 26

    Level 26: The slow lane

    AloneMedium

    Objective: Give the cgroup render a CPU weight of 20.

    cpu.weight sets a group's share of the CPU when everyone is busy: default 100, so 20 gets a fifth as much (docker run --cpu-shares, converted: 1024 shares = weight 100). The hard cap, cpu.max (--cpus), is left out of this little kernel.

    Commands taughtcpu-weight

    ▶ Play: The slow laneSOLUTION HIDDEN25 XP
  8. 27

    Level 27: Post-mortem

    AloneMedium

    Objective: Programs in the cgroup lab keep dying: tell Kern how many were killed for running out of memory.

    Each group keeps score in memory.events: the oom_kill line counts processes killed for using too much memory. That's what docker inspect calls OOMKilled.

    Commands taughtmemory-events

    ▶ Play: Post-mortemSOLUTION HIDDEN30 XP
  9. 28

    Level 28: Noisy neighbour

    Alone⏱ TimedHard

    Objective: Put sleep 7207 in a new cgroup tenant limited to 10 processes and 32 MiB of memory.

    A new tenant moves in. Fence it before it gets loud.

    ▶ Play: Noisy neighbourSOLUTION HIDDEN40 XP
  10. 29

    Level 29: Scales of justice

    Boss⏱ TimedHard

    Objective: Move sleep 7208 from lab into a new cgroup slow with 64 MiB and a CPU weight of 50, then tell Kern how many OOM kills lab has seen.

    A job is starving in a group too small for it.

    ▶ Play: Scales of justiceSOLUTION HIDDEN70 XP

World 4The Layer Cake

7 levels

OverlayFS stacks read-only layers under one writable layer: exactly how Docker images and containers share files.

  1. 30

    Level 30: Stacking glass

    GuidedEasy

    Objective: Mount an overlay on ~/layers/merged with lower as the bottom layer and upper for changes (work is the workdir).

    An overlay mount shows several folders as one: lowerdir is read-only, upperdir catches every change, workdir is overlay's scratch space, and the result appears at the mount point. Docker's image is the lower part, the container's own layer is the upper.

    Commands taughtoverlayfs

    ▶ Play: Stacking glassSOLUTION HIDDEN15 XP
  2. 31

    Level 31: Copy-up

    GuidedEasy

    Objective: Change ~/layers/merged/motd.txt to say patched, leaving the lower layer untouched.

    Lower layers are never changed: when you edit a lower file through the overlay, it's first copied up into upper, then changed there. That's why a hundred containers can share one image.

    Commands taughtcopy-up

    ▶ Play: Copy-upSOLUTION HIDDEN20 XP
  3. 32

    Level 32: Ghost files

    GuidedEasy

    Objective: Delete junk.bin from ~/layers/merged without touching the lower layer.

    Deleting a lower file can't touch the lower layer, so overlay leaves a whiteout in upper: an empty special file with the same name that means 'hide this'. ls -l shows it with a c (character device) and the numbers 0, 0.

    Commands taughtwhiteout

    ▶ Play: Ghost filesSOLUTION HIDDEN20 XP
  4. 33

    Level 33: Many layers

    AloneMedium

    Objective: Mount ~/layers/merged with app stacked on top of base (and upper, work for changes), so merged/version.txt comes from app.

    lowerdir can take several folders separated by colons, and the FIRST one is the top. Every Dockerfile instruction adds one such layer on top of the previous ones.

    Commands taughtoverlay-lowers

    ▶ Play: Many layersSOLUTION HIDDEN25 XP
  5. 34

    Level 34: Frozen image

    AloneMedium

    Objective: Mount ~/layers/ro as a read-only stack with app on top of base.

    Without upperdir and workdir an overlay is read-only: just the image's layers. Docker keeps images like that and adds a fresh upper per container.

    ▶ Play: Frozen imageSOLUTION HIDDEN25 XP
  6. 35

    Level 35: Upside down

    Alone⏱ TimedHard

    Objective: ~/layers/view has its layers upside down (version base, debug=true): remount it read-only with patch on top of app on top of base.

    A read-only view was mounted in a hurry, and the app now runs with the wrong settings. Find out where the files come from and fix the stack.

    ▶ Play: Upside downSOLUTION HIDDEN40 XP
  7. 36

    Level 36: The layer cake

    Boss⏱ TimedHard

    Objective: Mount ~/layers/box with app stacked on base plus your own upper, then from inside it (chroot) write cake into /etc/motd and delete /app/old.sh.

    Run a container on a two-layer image, the way Docker does. Nothing is prepared this time: you make your own upper, work and mount-point folders.

    ▶ Play: The layer cakeSOLUTION HIDDEN70 XP

World 5The Cargo Bay

9 levels

An image is a stack of tarballs plus a list of fingerprints: pack, unpack, layer, whiteout and verify them by hand.

  1. 37

    Level 37: Pack it up

    GuidedEasy

    Objective: Pack the root filesystem ~/cargo/rootfs into ~/cargo/image.tar, with paths starting at its root (./bin/…).

    Strip away the registry and a container image is tarballs of root filesystems. tar -C DIR -cf FILE . packs a folder's contents with paths starting at its root, like docker export.

    Commands taughtimage-tarball

    ▶ Play: Pack it upSOLUTION HIDDEN15 XP
  2. 38

    Level 38: Unpack and look

    GuidedEasy

    Objective: Unpack ~/cargo/kmini.tar into ~/cargo/run and tell Kern the PRETTY_NAME in the image's /etc/os-release.

    Running an image starts with unpacking it: tar -C DIR -xf FILE extracts into DIR. Then chroot into DIR and you're inside the image.

    ▶ Play: Unpack and lookSOLUTION HIDDEN20 XP
  3. 39

    Level 39: Layer by layer

    GuidedEasy

    Objective: Rebuild the image in ~/cargo/stack by unpacking layer1.tar, then layer2.tar on top.

    A real image is several layer tarballs; unpacking them in order into one folder rebuilds its filesystem, and later layers overwrite earlier files. Each Dockerfile line (FROM, COPY, RUN) made one of them.

    Commands taughtimage-layers

    ▶ Play: Layer by layerSOLUTION HIDDEN20 XP
  4. 40

    Level 40: A note that deletes

    GuidedEasy

    Objective: Apply ghost.tar to ~/cargo/stack: unpack it, then do what its one .wh. marker says, by hand, and remove the marker.

    A layer tarball can't hold 'nothing', so it marks a deletion with an empty file named .wh.NAME next to where NAME was: it means 'delete NAME'. tar doesn't know that rule: after unpacking, the engine deletes NAME and removes the marker.

    Commands taughtoci-whiteout

    ▶ Play: A note that deletesSOLUTION HIDDEN20 XP
  5. 41

    Level 41: Whiteout notes

    AloneMedium

    Objective: Apply layer3.tar to ~/cargo/stack the way Docker does: every .wh.NAME deletes NAME, and no .wh. files remain.

    Same rule as the last level, more markers: every .wh.NAME in the layer means 'delete NAME'. After unpacking, apply each one and remove the marker. hidden lists them all.

    ▶ Play: Whiteout notesSOLUTION HIDDEN30 XP
  6. 42

    Level 42: Clean slate

    AloneMedium

    Objective: Apply layer4.tar to ~/cargo/stack the way Docker does: its app/ has an opaque marker, so afterwards app/ holds only what layer4 brings, and no marker.

    A layer that replaces a whole folder puts one opaque marker in it: .wh..wh..opq means 'forget everything earlier layers put in this folder'. Apply it by emptying the folder BEFORE unpacking the layer, then remove the marker.

    ▶ Play: Clean slateSOLUTION HIDDEN30 XP
  7. 43

    Level 43: Fingerprints

    AloneMedium

    Objective: Write ~/cargo/manifest.txt with one line per layer, layer1.tar to layer3.tar in order, each holding sha256:<digest> of that layer.

    Images name their layers by content: the sha256 digest of each tarball (sha256sum FILE), and a manifest is the ordered list of those digests. Ours is the simple version: a real OCI manifest is JSON, with gzip layers and a config file.

    Commands taughtdigest

    ▶ Play: FingerprintsSOLUTION HIDDEN25 XP
  8. 44

    Level 44: Tampered cargo

    Alone⏱ TimedHard

    Objective: One layer in ~/cargo/shipment doesn't match its digest in manifest.txt: tell Kern its file name.

    Someone opened a crate on the dock.

    ▶ Play: Tampered cargoSOLUTION HIDDEN40 XP
  9. 45

    Level 45: Ship it

    Boss⏱ TimedHard

    Objective: Unpack the image in ~/cargo/ship into ~/cargo/live in manifest.txt order, honouring whiteouts, then run /app/run.sh inside it with chroot.

    A whole image, crate by crate.

    ▶ Play: Ship itSOLUTION HIDDEN70 XP

World 6The Dock

9 levels

Everything you built, in one script: minidock pulls images and runs them with namespaces, cgroups and a container layer.

  1. 46

    Level 46: minidock run

    GuidedEasy

    Objective: Fill in TODO L1 of ~/bin/minidock (shift already ran; exec chroot) so sudo ~/bin/minidock run ~/dock/rootfs CMD… runs CMD in that folder, exit code kept.

    docker run glues together tricks you already know, and Kern's skeleton in ~/bin/minidock has TODO lines tagged L1 to L9, one set per level of the Dock. Step one is the oldest trick: chroot into the root filesystem it's given and exec the command there.

    Commands taughtminidockdocker-map

    ▶ Play: minidock runSOLUTION HIDDEN20 XP
  2. 47

    Level 47: Masks on

    GuidedEasy

    Objective: Fill in TODO L2: minidock run must start the command in new UTS, PID and mount namespaces, still chrooted into the rootfs.

    A container gets its own namespaces before it gets its root. Put unshare -u -p -m -f in front of chroot: the command is then PID 1 of a new PID namespace, and hostnames and mounts made inside stay inside.

    ▶ Play: Masks onSOLUTION HIDDEN20 XP
  3. 48

    Level 48: A fresh /proc

    GuidedEasy

    Objective: Fill in TODO L3: inside the chroot, mount a fresh proc on /proc, then exec the command, so ps in the container shows only its own processes.

    To mount proc inside the container, minidock needs a tiny shell script to run there first: /bin/sh -c 'mount -t proc proc /proc; exec "$@"', followed by the command. sh -c 'SCRIPT' A B C sets $0=A and $@=B C, so put a placeholder word (sh) before the command.

    ▶ Play: A fresh /procSOLUTION HIDDEN25 XP
  4. 49

    Level 49: Name tags, again

    GuidedEasy

    Objective: Teach minidock run a --hostname NAME flag (docker run --hostname), keeping everything that already works.

    Flags turn into kernel settings: --hostname NAME becomes a hostname call inside the new UTS namespace. Parse flags in a while loop before the rootfs argument.

    ▶ Play: Name tags, againSOLUTION HIDDEN25 XP
  5. 50

    Level 50: Weights and measures

    AloneMedium

    Objective: Add --memory SIZE and --pids N to minidock run, applied through a cgroup per container.

    --memory and --pids become a cgroup: make /sys/fs/cgroup/minidock/<id>, write memory.max and pids.max, and move the script itself in before it starts the container (children inherit the group). minidock is the yard, each container a pen (Boxes in boxes).

    ▶ Play: Weights and measuresSOLUTION HIDDEN35 XP
  6. 51

    Level 51: Pull

    AloneMedium

    Objective: Add minidock pull TAR NAME (unpack into /var/lib/minidock/images/NAME) and let run take an image name.

    Engines keep images by name in their own folder (Docker: /var/lib/docker). Here that's /var/lib/minidock, a tmpfs: pull TAR NAME unpacks into images/NAME, and run accepts a NAME.

    ▶ Play: PullSOLUTION HIDDEN30 XP
  7. 52

    Level 52: The container layer

    AloneMedium

    Objective: Make minidock run IMAGE use an overlay with a fresh upper per container, so the image never changes.

    Right now a container can scribble on its image. Docker never lets that happen: each run mounts an overlay with the image as lowerdir and a fresh upper for that container.

    ▶ Play: The container layerSOLUTION HIDDEN40 XP
  8. 53

    Level 53: Leave no trace

    GuidedEasy

    Objective: Fill in TODO L8: minidock run returns the container's exit code and does rmdir on its cgroup, leaving none in /sys/fs/cgroup/minidock.

    For --rm, minidock must outlive its container: no exec in front of unshare, and rc=$? keeps the exit code. A cgroup can only be removed when empty and the script sits in it, so move $$ back to the root group, remove the container's group, then exit $rc.

    ▶ Play: Leave no traceSOLUTION HIDDEN30 XP
  9. 54

    Level 54: Ship it

    Boss⏱ TimedHard

    Objective: Pass the full inspection: pull, run with every flag on a container layer, return the exit code, and leave no mount, folder or cgroup behind (docker run --rm).

    The full inspection: every feature at once, and a clean dock afterwards. Your TODO L9 line is the last piece: like the cgroup, a container layer must go when its container ends.

    ▶ Play: Ship itSOLUTION HIDDEN80 XP

World 7The Recipe

9 levels

Write Dockerfiles, the recipes a real engine follows to bake images, and run what comes out.

  1. 55

    Level 55: First recipe

    GuidedEasy

    Objective: In ~/recipe, write a Dockerfile FROM busybox whose CMD is ["echo", "hello from my image"], build it as hello and run it.

    A Dockerfile is a recipe: FROM picks the base image, CMD is the command a container runs by default. docker build -t NAME . bakes the recipe in this folder into an image, and docker run NAME starts a container from it.

    Commands taughtdocker-is-podmandockerfiledocker-builddocker-run

    ▶ Play: First recipeSOLUTION HIDDEN20 XP
  2. 56

    Level 56: Bring your own files

    GuidedEasy

    Objective: Build cafe:1 FROM busybox with ~/recipe/index.html copied to /www/index.html and CMD ["cat", "/www/index.html"].

    COPY SRC DEST copies files from the build context (the folder you build) into the image. Paths on the left are relative to that folder; the right side is a path inside the image.

    Commands taughtdf-copy

    ▶ Play: Bring your own filesSOLUTION HIDDEN20 XP
  3. 57

    Level 57: Every RUN a layer

    GuidedEasy

    Objective: Build cafe:2 from cafe:1's recipe plus a RUN that writes soup of the day into /www/menu.txt, then list its layers with docker history.

    RUN runs a command inside the image while it's being built, and the files it changes become a new layer. docker history IMAGE lists the layers, newest first, with the instruction that made each one and its size.

    Commands taughtdf-rundocker-history

    ▶ Play: Every RUN a layerSOLUTION HIDDEN25 XP
  4. 58

    Level 58: Pick a workbench

    GuidedEasy

    Objective: Build cafe:3 FROM busybox with WORKDIR /www, index.html copied there with a relative path, and CMD ["ls"].

    WORKDIR /www makes /www the current folder for the next instructions and for the running container (it creates it if needed). After it, COPY index.html . lands in /www.

    Commands taughtdf-workdir

    ▶ Play: Pick a workbenchSOLUTION HIDDEN20 XP
  5. 59

    Level 59: A value from outside

    GuidedEasy

    Objective: Run stamp:9 and read its /version.

    ARG NAME=default declares a build-time value; docker build --build-arg NAME=value overrides it. It exists only while the image is built.

    Commands taughtdf-arg

    ▶ Play: A value from outsideSOLUTION HIDDEN20 XP
  6. 60

    Level 60: House settings

    AloneMedium

    Objective: Build greeter (it runs ~/recipe/greet.sh) with GUEST=stranger as its default, then run it once with GUEST set to Ada.

    ENV NAME=value bakes an environment variable into the image, as a default. docker run -e NAME=other overrides it for one container, without rebuilding.

    Commands taughtdf-env

    ▶ Play: House settingsSOLUTION HIDDEN25 XP
  7. 61

    Level 61: Build-time knobs

    AloneMedium

    Objective: Build cafe:2.1 whose /version file holds 2.1, set with --build-arg VERSION=2.1 (the Dockerfile's default stays dev).

    ARG NAME=default declares a build argument: RUN steps can read $NAME, and docker build --build-arg NAME=value changes it. Unlike ENV it's gone when the container runs.

    ▶ Play: Build-time knobsSOLUTION HIDDEN25 XP
  8. 62

    Level 62: Kitchen disaster

    Alone⏱ TimedHard

    Objective: Fix ~/recipe/Dockerfile so hidden works and running cafe:fixed prints the café page.

    Someone wrote this recipe in a hurry. Read the build errors: they name the line that failed.

    ▶ Play: Kitchen disasterSOLUTION HIDDEN40 XP
  9. 63

    Level 63: Opening night

    Boss⏱ TimedHard

    Objective: Write ~/recipe/Dockerfile for cafe:1.0: the site in /www, a version stamp from --build-arg, a GREETING default and a web server command.

    Put every recipe step together: the café's site, a version stamp, a default setting and a server command.

    ▶ Play: Opening nightSOLUTION HIDDEN80 XP

World 8The Kitchen

9 levels

Finer recipes: who is PID 1, entrypoints, users, ports on paper, two-stage builds and the build cache.

  1. 64

    Level 64: Who is PID 1?

    GuidedEasy

    Objective: Build kitchen:2 from ~/kitchen so app.sh is PID 1 (WORKDIR /app plus an exec-form CMD) and docker stop ends it cleanly with exit code 0.

    CMD in shell form (CMD cd /app && ./app.sh) runs /bin/sh -c as PID 1, and that shell neither handles nor passes on the SIGTERM that docker stop sends, so after 10 s Docker kills it (exit 137). Exec form (CMD ["./app.sh"]) makes your app PID 1, so its TERM handler runs.

    Commands taughtdf-cmd-forms

    ▶ Play: Who is PID 1?SOLUTION HIDDEN25 XP
  2. 65

    Level 65: The house blend

    GuidedEasy

    Objective: Build brew from ~/kitchen/brew.sh with ENTRYPOINT ["/brew.sh"] and CMD ["espresso"], run it plain, then run it once asking for latte.

    ENTRYPOINT ["prog"] is the program that always runs; CMD ["arg"] becomes its default arguments. docker run IMAGE latte replaces only the CMD, so the image behaves like a command.

    Commands taughtdf-entrypoint

    ▶ Play: The house blendSOLUTION HIDDEN25 XP
  3. 66

    Level 66: Not the head chef

    GuidedEasy

    Objective: Build cook:1 FROM busybox that adds the user cook with uid 10001, runs as cook and has CMD ["id", "-u"].

    Containers run as root (uid 0) unless the image says otherwise, and that root is the host's root if anything breaks out. RUN adduser makes a user and USER NAME switches every later step and the container to it.

    Commands taughtdf-user

    ▶ Play: Not the head chefSOLUTION HIDDEN25 XP
  4. 67

    Level 67: Ports on paper

    GuidedEasy

    Objective: Build menu:1 with EXPOSE 8080, then find which port the image mystery:1 documents and tell Kern with kern PORT.

    EXPOSE 8080 only writes into the image's settings which port the app listens on: it opens nothing. docker inspect shows it under ExposedPorts; publishing a port is docker run -p.

    Commands taughtdf-exposedocker-inspect

    ▶ Play: Ports on paperSOLUTION HIDDEN25 XP
  5. 68

    Level 68: Two kitchens

    GuidedEasy

    Objective: Build menu:2: compile menu.kc with kern-cc in a kern/sdk:1 stage named build, then copy only /menu into busybox as /usr/local/bin/menu, CMD ["menu"].

    A multi-stage Dockerfile has several FROM lines: an early stage (FROM sdk AS build) has the heavy tools and builds the program, and the last stage only does COPY --from=build of the result. Only the last stage ends up in the image.

    Commands taughtdf-multistage

    ▶ Play: Two kitchensSOLUTION HIDDEN30 XP
  6. 69

    Level 69: Not in my soup

    AloneMedium

    Objective: Without touching the Dockerfile, make hidden give an image with no secrets.env and no logs/ in /app.

    docker build sends the whole context folder to the engine, and COPY . copies all of it. A .dockerignore file next to the Dockerfile lists paths to leave out (secrets.env, logs/, .git), like .gitignore.

    Commands taughtdockerignore

    ▶ Play: Not in my soupSOLUTION HIDDEN30 XP
  7. 70

    Level 70: Prep before service

    AloneMedium

    Objective: Reorder ~/kitchen/Dockerfile so install.sh runs after copying only deps.txt and install.sh, with the rest copied after it, and build it as shop:2.

    Each step is cached and reused until one of its inputs changes; then that step and every step after it rebuild. So copy what changes rarely (the dependency list) and install it first, and copy the code that changes often last.

    Commands taughtbuild-cache

    ▶ Play: Prep before serviceSOLUTION HIDDEN30 XP
  8. 71

    Level 71: Diet plan

    Alone⏱ TimedHard

    Objective: Build menu:slim under 3 MB that still prints the menu from ~/kitchen/menu.kc when run.

    The menu image ships the whole toolchain. Make it small without changing what it prints.

    ▶ Play: Diet planSOLUTION HIDDEN45 XP
  9. 72

    Level 72: Health inspection

    Boss⏱ TimedHard

    Objective: Build cafe:2.0 from ~/kitchen: a two-stage menu program, run as cook, menu as the ENTRYPOINT, port 8080 documented and the site files with no secrets.

    The inspector checks every rule of a good image: small, not root, a real PID 1, documented ports, no secrets, cache-friendly order.

    ▶ Play: Health inspectionSOLUTION HIDDEN90 XP

World 9The Wiring

10 levels

Plug real containers into a bridge by hand: cables, addresses, routes and NAT, exactly what docker run does for you.

  1. 73

    Level 73: A cable in the wall

    GuidedEasy

    Objective: Make a veth pair kv-web on the host whose other end is eth0 inside the container web.

    A container started with --network none has only lo. Docker gives it a network with a veth pair: one end stays on the host, the other is moved into the container's network namespace, found through its PID (docker inspect).

    Commands taughtwire-pidwire-veth

    ▶ Play: A cable in the wallSOLUTION HIDDEN20 XP
  2. 74

    Level 74: The switchboard

    GuidedEasy

    Objective: Create the bridge dock0 with 172.18.0.1/24, bring it up, and plug kv-web into it (up too).

    Docker plugs every container's host-side veth into one bridge, docker0, which acts as a switch and holds the containers' gateway address. We call ours dock0, with 172.18.0.1/24.

    Commands taughtwire-bridge

    ▶ Play: The switchboardSOLUTION HIDDEN20 XP
  3. 75

    Level 75: An address

    GuidedEasy

    Objective: Give web's eth0 the address 172.18.0.2/24 and bring it up, so the host can reach http://172.18.0.2/.

    Inside the container, eth0 needs an address on the bridge's subnet and must be up; Docker hands out 172.17.0.2, .3 and so on. nsenter -t PID -n runs ip inside the container's network namespace, as root.

    Commands taughtwire-ip

    ▶ Play: An addressSOLUTION HIDDEN20 XP
  4. 76

    Level 76: The way out

    GuidedEasy

    Objective: Give web a default route via 172.18.0.1.

    A container only knows its own /24 until it gets a default route: send everything else to the gateway, the bridge's address. Docker adds default via 172.17.0.1 to every container.

    ▶ Play: The way outSOLUTION HIDDEN20 XP
  5. 77

    Level 77: A rule at the door

    GuidedEasy

    Objective: Delete your rule again: same words, but -D instead of -A.

    NAT rules live in iptables' nat table. A DNAT rule rewrites the destination of packets that match: this is how a published port reaches a container.

    Commands taughtwire-dnat

    ▶ Play: A rule at the doorSOLUTION HIDDEN25 XP
  6. 78

    Level 78: Masquerade

    AloneMedium

    Objective: Let web reach the outside server isp at http://198.51.100.2/ (isp has no route back to your containers).

    To reach the outside, the host must forward packets (net.ipv4.ip_forward=1) and hide the containers behind its own address, because the outside has no route back to 172.18.0.0/24. Docker adds POSTROUTING -s SUBNET ! -o docker0 -j MASQUERADE.

    Commands taughtwire-masquerade

    ▶ Play: MasqueradeSOLUTION HIDDEN30 XP
  7. 79

    Level 79: Publish by hand

    AloneMedium

    Objective: Make port 8080 on the host's outside address 198.51.100.1 reach web's port 80, and test it from isp.

    docker run -p 8080:80 adds a DNAT rule in nat PREROUTING: packets for the host's port 8080 get their destination rewritten to the container's IP and port 80. Replies are rewritten back by connection tracking.

    Commands taughtwire-dnat

    ▶ Play: Publish by handSOLUTION HIDDEN30 XP
  8. 80

    Level 80: Names, not numbers

    AloneMedium

    Objective: Make http://api/ work from inside web (api is the container at 172.18.0.3).

    Apps call each other by name, not IP. Docker's user networks answer names with a small DNS server; the older way, still used by --add-host and podman, is a line in the container's /etc/hosts.

    Commands taughtwire-hosts

    ▶ Play: Names, not numbersSOLUTION HIDDEN25 XP
  9. 81

    Level 81: Who's talking?

    Alone⏱ TimedHard

    Objective: One container keeps calling isp: tell Kern its name with kern NAME.

    Someone keeps calling the outside server. After MASQUERADE every packet looks like the host's, so sniff where the containers' own addresses are still visible.

    Commands taughtwire-tcpdump

    ▶ Play: Who's talking?SOLUTION HIDDEN40 XP
  10. 82

    Level 82: Wire the kitchen

    Boss⏱ TimedHard

    Objective: Wire the container shop end to end: cable on dock0, address 172.18.0.4 with a route, and host port 9090 published to its port 80.

    Do everything docker run does for networking, for a brand-new container, from cable to published port.

    ▶ Play: Wire the kitchenSOLUTION HIDDEN80 XP

World 10The Ports

7 levels

Publish ports and pick network modes with one flag each, now that you know what they do underneath.

  1. 83

    Level 83: Open the door

    GuidedEasy

    Objective: Run kern/cafe:1 in the background as menu with host port 8080 published to its port 80, and fetch the page with curl.

    docker run -d starts a container in the background; -p 8080:80 publishes it: connections to the host's port 8080 are forwarded to port 80 inside. hidden shows the mapping in its PORTS column.

    Commands taughtport-publish

    ▶ Play: Open the doorSOLUTION HIDDEN20 XP
  2. 84

    Level 84: Only for us

    GuidedEasy

    Objective: Run kern/cafe:1 as admin, reachable only from this machine on port 8081, then check it with hidden.

    -p 8080:80 listens on every address of the host, so the whole network can connect. -p 127.0.0.1:8081:80 listens on localhost only; docker port NAME shows what a container publishes.

    Commands taughtport-bind

    ▶ Play: Only for usSOLUTION HIDDEN20 XP
  3. 85

    Level 85: No walls

    GuidedEasy

    Objective: Run kern/cafe:1 as hostweb with --network host, its httpd listening on port 8082 (httpd -f -p 8082 -h /www).

    --network host skips the network namespace: the container uses the host's interfaces and ports directly, so -p does nothing. Fastest, but no isolation and port clashes are your problem.

    Commands taughtport-host

    ▶ Play: No wallsSOLUTION HIDDEN20 XP
  4. 86

    Level 86: The sidecar

    GuidedEasy

    Objective: Run busybox as probe (hidden00, in the background) sharing menu's network, and fetch menu's page from it on 127.0.0.1.

    --network container:NAME puts a new container into NAME's network namespace: same interfaces, same localhost. A sidecar (a probe, a proxy) talks to the app on 127.0.0.1; a Kubernetes pod is built exactly like this.

    Commands taughtport-container

    ▶ Play: The sidecarSOLUTION HIDDEN25 XP
  5. 87

    Level 87: Air gap

    AloneMedium

    Objective: Run busybox as vault in the background (hidden00) with no network at all, then confirm inside that only lo exists.

    --network none gives a container only lo: no cable, no route, nothing in or out. Batch jobs that handle secrets or untrusted files often run like this.

    Commands taughtport-none

    ▶ Play: Air gapSOLUTION HIDDEN25 XP
  6. 88

    Level 88: Connection refused

    Alone⏱ TimedHard

    Objective: Make http://127.0.0.1:8083/ serve the café page from a container named menu (kern/cafe:1), replacing the broken one.

    menu is published on 8083, yet customers get connection refused. Published traffic arrives on the container's network card, not on its localhost: a server started on 127.0.0.1 never sees it. The image's default command listens on every address.

    Commands taughtport-listen

    ▶ Play: Connection refusedSOLUTION HIDDEN40 XP
  7. 89

    Level 89: Grand opening

    Boss⏱ TimedHard

    Objective: Start the café's four containers with the right network for each: front, health, stats and metrics.

    Four containers, four network setups: pick the right mode for each.

    ▶ Play: Grand openingSOLUTION HIDDEN80 XP

World 11The Holds

10 levels

Containers forget everything when they go: give them holds where data stays, from bind mounts to volumes on their own disks.

  1. 90

    Level 90: A window to the host

    GuidedEasy

    Objective: Run a busybox container with ~/holds/notes mounted at /notes that writes hello from inside into /notes/inside.txt.

    A container's own files vanish with it. -v /host/folder:/path mounts a host folder into the container (a bind mount): what the container writes there lands straight on the host.

    Commands taughtbind-mount

    ▶ Play: A window to the hostSOLUTION HIDDEN20 XP
  2. 91

    Level 91: Look, don't touch

    GuidedEasy

    Objective: Run a container named cfg that cats /etc/app/app.conf, with ~/holds/config mounted read-only at /etc/app.

    Add :ro to a mount (-v HOST:CT:ro) and the container can read it but never write: config and secrets should come in this way. docker rm NAME deletes a stopped container.

    ▶ Play: Look, don't touchSOLUTION HIDDEN20 XP
  3. 92

    Level 92: The pantry

    GuidedEasy

    Objective: Create the volume pantry, write 12 jars into stock.txt on it from a busybox container, and look up its Mountpoint with docker volume inspect.

    A named volume is storage the engine manages for you: docker volume create NAME makes it, -v NAME:/path mounts it (no slash in front = a volume). docker volume inspect shows its Mountpoint, the real folder on the host.

    Commands taughtdocker-volume

    ▶ Play: The pantrySOLUTION HIDDEN20 XP
  4. 93

    Level 93: The ledger remembers

    GuidedEasy

    Objective: Write 3 coffees into sales.txt on the volume ledger from a --rm container, then read it back from a second --rm container.

    Removing a container removes its top layer, never its volumes: the next container that mounts the volume finds the data. If -v names a volume that doesn't exist yet, docker creates it.

    ▶ Play: The ledger remembersSOLUTION HIDDEN25 XP
  5. 94

    Level 94: A disk of its own

    GuidedEasy

    Objective: Attach /tmp/vault.img (an ext4 image) to a loop device, create the volume vault on it, and store gold in /data/gold.txt through it.

    losetup -f --show FILE turns a disk image into a block device (/dev/loopN). docker volume create --opt type=ext4 --opt device=/dev/loopN NAME makes a volume that mounts that disk, like a cloud volume attached to a server.

    Commands taughtblock-volume

    ▶ Play: A disk of its ownSOLUTION HIDDEN25 XP
  6. 95

    Level 95: Memory only

    AloneMedium

    Objective: Run a container named scratch, with a tmpfs at /cache, that prints df /cache.

    --tmpfs /path mounts a fresh in-memory filesystem there: fast, never written to disk, gone when the container stops. Good for caches and scratch files.

    Commands taughttmpfs-mount

    ▶ Play: Memory onlySOLUTION HIDDEN25 XP
  7. 96

    Level 96: Not your shelf

    AloneMedium

    Objective: till:2 runs as nobody and can't write to the orders volume: fix the volume's ownership so hidden works.

    Numbers, not names, own files: data a root container wrote belongs to uid 0, so an image that switches to USER nobody (65534) gets Permission denied there. Fix the data's owner, from a container: chown -R nobody /data.

    Commands taughtvolume-ownership

    ▶ Play: Not your shelfSOLUTION HIDDEN30 XP
  8. 97

    Level 97: Pack it, unpack it

    AloneMedium

    Objective: Back up the volume recipes into ~/holds/backup/recipes.tar, then restore that tar into a new volume recipes2.

    To back up a volume, mount it AND a host folder into a throwaway container and tar one into the other: tar cf /backup/x.tar -C /data . Restoring is the same run backwards, into a new volume.

    Commands taughtvolume-backup

    ▶ Play: Pack it, unpack itSOLUTION HIDDEN30 XP
  9. 98

    Level 98: Who ate the disk?

    Alone⏱ TimedHard

    Objective: Find the volume eating the disk (tell Kern its name), remove it, and rerun scratchy with a tmpfs at /cache instead.

    hidden lists every image, container and volume with its size. Throwaway cache belongs in a tmpfs, not on a volume that grows forever.

    Commands taughtdocker-system-df

    ▶ Play: Who ate the disk?SOLUTION HIDDEN45 XP
  10. 99

    Level 99: Moving day

    Boss⏱ TimedHard

    Objective: Put the café's sqlite database on its own disk, back it up, then upgrade to cafe-db:2 without losing an order.

    The café's database must survive an upgrade: its own disk, a backup first, then the new version against the same data.

    ▶ Play: Moving daySOLUTION HIDDEN90 XP

World 12The Shift

8 levels

Night shift on a container host: start things in the background, read their logs, step inside and stop them properly.

  1. 100

    Level 100: Into the background

    GuidedEasy

    Objective: Start a background container named web from busybox running httpd -f -p 8080 -h /etc, then list the running containers.

    docker run -d starts a container in the background and prints its ID; --name gives it a name you can use instead. hidden lists the running containers, hidden the stopped ones too.

    Commands taughtdocker-ps

    ▶ Play: Into the backgroundSOLUTION HIDDEN20 XP
  2. 101

    Level 101: What did it say?

    GuidedEasy

    Objective: The container chatty reported a failed order: read its logs and tell Kern the order number with kern NUMBER.

    Whatever a container's main process prints goes to its log: docker logs NAME shows it all, --tail N only the last N lines, -f keeps following (Ctrl-C stops). Here podman keeps the log in a file (log driver k8s-file); Docker's default is json-file.

    Commands taughtdocker-logs

    ▶ Play: What did it say?SOLUTION HIDDEN20 XP
  3. 102

    Level 102: Step inside

    GuidedEasy

    Objective: The container vault keeps a code in /data/key.txt inside it: read it with docker exec and tell Kern the code.

    docker exec NAME COMMAND runs one more process inside a running container: same namespaces, same files, same cgroup (it's nsenter, from the Hall of Masks). docker exec -it NAME sh gives you a shell in there.

    Commands taughtdocker-exec

    ▶ Play: Step insideSOLUTION HIDDEN20 XP
  4. 103

    Level 103: Lights out

    GuidedEasy

    Objective: Stop the container polite with docker stop and kill the container stubborn (it ignores SIGTERM) with docker kill.

    docker stop sends SIGTERM, waits (10 s, or -t N) for a clean exit, then sends SIGKILL; docker kill sends SIGKILL at once. A death by signal shows as 128 + the signal: 143 for SIGTERM (15), 137 for SIGKILL (9).

    Commands taughtdocker-stop

    ▶ Play: Lights outSOLUTION HIDDEN25 XP
  5. 104

    Level 104: Read the label

    AloneMedium

    Objective: Tell Kern the host PID of the main process of the container mystery with kern PID.

    docker inspect NAME prints everything the engine knows about a container as JSON; --format (-f) picks one field with a Go template, like '{{.State.Pid}}' or '{{.Config.Env}}'.

    ▶ Play: Read the labelSOLUTION HIDDEN25 XP
  6. 105

    Level 105: Settings by the file

    AloneMedium

    Objective: Write ~/shift/app.env with MODE=night and WORKERS=3, and start container api from busybox (sleep 3600) in the background with that file.

    --env-file PATH reads KEY=value lines from a file and sets them all, like many -e flags; it keeps settings out of your shell history and next to the app.

    Commands taughtenv-file

    ▶ Play: Settings by the fileSOLUTION HIDDEN25 XP
  7. 106

    Level 106: Morning report

    Alone⏱ TimedHard

    Objective: Tell Kern which job hit a missing command and which one was killed: kern <127-job> <137-job>.

    Four jobs ran overnight and stopped. Exit codes below 128 come from the program itself (127: command not found, 126: found but not runnable); above 128 it died from a signal (137 = SIGKILL, the OOM killer or docker kill).

    Commands taughtexit-codes

    ▶ Play: Morning reportSOLUTION HIDDEN40 XP
  8. 107

    Level 107: Pager at 3 a.m.

    Boss⏱ TimedHard

    Objective: Bring the shop back: diagnose the dead container, run a fixed shop2 from the same image, check it from inside and remove the old one.

    The shop container is down. Find out why, start a fixed one next to it, prove it works and clean up.

    ▶ Play: Pager at 3 a.m.SOLUTION HIDDEN80 XP

World 13The Night Watch

7 levels

Keep containers healthy all night: clean stops, reaped zombies, automatic restarts, free disk and upgrades nobody notices.

  1. 108

    Level 108: Deaf PID 1

    GuidedEasy

    Objective: Add a SIGTERM trap to ~/watch/app.sh that prints bye and exits 0, rebuild watch:1 and check that docker stop is now quick.

    The kernel gives PID 1 of a namespace no default signal actions: a SIGTERM it has no handler for is simply ignored, so docker stop waits 10 s and then kills it. A shell script gets a handler with trap 'cleanup; exit 0' TERM.

    Commands taughtpid1-signals

    ▶ Play: Deaf PID 1SOLUTION HIDDEN25 XP
  2. 109

    Level 109: The night porter

    GuidedEasy

    Objective: Start worker in the background from busybox running sleep 3600 with --init, look at its processes, then docker stop it.

    docker run --init makes a tiny init (here catatonit, in Docker tini) PID 1: it passes signals on to your program and reaps zombies, the dead children nobody waited for. Your program then dies from SIGTERM normally: exit 143.

    Commands taughtdocker-init

    ▶ Play: The night porterSOLUTION HIDDEN25 XP
  3. 110

    Level 110: Get back up

    GuidedEasy

    Objective: Run flaky (busybox, sh -c 'sleep 1; exit 3') in the background with --restart on-failure:3 and tell Kern its RestartCount once it gives up.

    --restart on-failure:N tells the engine to start a container again when it exits with a non-zero code, at most N times (always and unless-stopped restart on any exit). docker inspect shows the count in .RestartCount.

    Commands taughtrestart-policy

    ▶ Play: Get back upSOLUTION HIDDEN25 XP
  4. 111

    Level 111: Sweep the floor

    AloneMedium

    Objective: Remove every stopped container and dangling image, but keep the running container keep and its image keep:1.

    hidden shows the space used by images, containers and volumes, and how much is reclaimable. docker system prune removes stopped containers and dangling images (old builds with no name); volumes only with --volumes.

    Commands taughtdocker-prune

    ▶ Play: Sweep the floorSOLUTION HIDDEN25 XP
  5. 112

    Level 112: Ten long seconds

    Alone⏱ TimedHard

    Objective: Fix ~/watch/Dockerfile so a container of slowpoke:1 (rebuilt) stops within 3 seconds of docker stop.

    slowpoke's serve.sh has a trap, but docker stop still takes 10 s. Shell form CMD with && keeps /bin/sh as PID 1, and sh doesn't pass SIGTERM on.

    ▶ Play: Ten long secondsSOLUTION HIDDEN45 XP
  6. 113

    Level 113: Disk almost full

    Alone⏱ TimedHard

    Objective: Free at least 10 MB of engine storage without losing the orders volume or stopping the running container shop.

    The engine's storage is filling up with leftovers from crashed jobs. Free space, but some unused-looking things hold real data.

    ▶ Play: Disk almost fullSOLUTION HIDDEN45 XP
  7. 114

    Level 114: Changing the guard

    Boss⏱ TimedHard

    Objective: Roll the café from web:1 to web:2 with no downtime: start web2 in the pod, point the proxy at it with a reload, then retire web1.

    The café runs as a pod: an nginx proxy on port 8080 with web1 (version 1) behind it. Roll out version 2 without the proxy ever going down: start new, check, switch, retire old.

    Commands taughtpodman-pod

    ▶ Play: Changing the guardSOLUTION HIDDEN90 XP

For teachers

Use these levels with a class

SOLUTION HIDDEN Teachers see answer keys in the classroom.

For teachers
ROOTSPIRE
DiscsFor teachers
▶ Play freeLibrary 16 discsDiscsFor teachersLog in