Free courses · 17 puzzles · Final project
Docker from the kernel up
What a container really is underneath docker run: one ordinary Linux process, fenced in by namespaces and held to limits by cgroups, on the same kernel as everything else. Every puzzle shows real output from a real machine, and you can run the same commands yourself. For Android and Kotlin engineers who use Docker but have never looked under it.
Course outline
Module 1: What a container really is9 puzzles
Find a container's program in the host's process list, compare it with a virtual machine, then open the fence one piece at a time: process IDs, files, hostname and network, users and capabilities, memory limits, processor time, and finally who builds it all when you type docker run.
- A container is a process Docker starts a program for you. Find that program on the machine, and see the one thing that makes it different from every other program running there.
- One kernel, or many? Puzzle 0's container is a process on the host's kernel. So which kernel does it really use, the host's or one that came with its image? And how is that different from a virtual computer?
- Whose PID 1? Inside puzzle 0's container, sleep was PID 1; on the host, the same process was 3393. Here's how one process gets two numbers, and why it can't see anything outside.
- A file tree of its own Puzzle 1's Alpine container read a different /etc/os-release from the host's, on the same kernel. Here's the second fence: how a process gets its own file tree, and where a container's tree comes from.
- A namespace per resource Puzzles 2 and 3 fenced off process IDs and files. A program also reads its machine's name and talks through the network. Here's how to read, for any process, which fences it has, and what two more of them change.
- Root in the container is root on the host Puzzle 4's table showed one link that matched the host's, user. Here's what that one equal number means when a container's program touches a file on the host, and the namespace that would change it.
- How much memory may it use? The namespaces of puzzles 2 to 5 decide what a container can see. Nothing so far stops it from taking all of the machine's memory. Here's the other half of the fence, what happens at its edge, and why the program inside never sees it.
- How much processor time? Puzzle 6's cgroup held memory to a limit. Processor time is the other thing a busy container takes from its neighbours. Here's how the same group limits it, and why a limited container can wait while the processors sit idle.
- Who builds the container? Puzzles 0 to 7 took the fence apart: namespaces and a cgroup around one process. Somebody asks the kernel for all of it when you type docker run. Here's the chain of programs that does, and the one file that describes the whole container.
Module 2: Images8 puzzles
Open an image file by file: layers and whiteouts, how the overlay filesystem stacks them, the container's own writable layer, where Docker 29 keeps it all, digests that name content, tags that move, how a registry hands an image out, and the index that serves many machines.
- What is inside an image? Module 1 treated an image as "the files a container starts from". Here's what an image really is on disk, file by file, and how one small change becomes part of a new image without copying the rest.
- Stacking layers into one tree Puzzle 9's image is a stack of separate layers, yet the container sees one ordinary file tree that it can even write to. Here's the kernel feature that stacks them, and what really happens when a container changes or deletes a file the image provides.
- The container's own layer Puzzle 10's overlay mount gives each container one writable directory on top of the image. Here's what that means for the files a program writes: who can see them, what keeps them, and the one command that throws them away.
- Where images live on disk Puzzles 9 to 11 followed layers from a tar archive to an overlay mount. Here's where Docker keeps them in between, why an image takes more disk than its download, and how to tell which of Docker's two ways of storing images your machine uses.
- Named by its content Puzzle 9's blobs had 64-character names, and the image config listed its layer under yet another one. Here's where those names come from, why no two different contents get the same one, and what that lets Docker skip and check.
- Tags move, digests don't Puzzle 13 named every image by its content. People don't type 64 characters, so images also get short names like 3.20 and latest. Here's what those names really are, why the same name can give you a different image tomorrow, and how to ask for exactly one image.
- Pulling from a registry Puzzle 14 pushed images to a registry and pulled them by tag and by digest. Here's what a pull really sends over the network: which questions, in which order, and why a second image built on the same base downloads almost nothing.
- One name, many machines Puzzles 9 to 15 took apart one image for one kind of machine. But the same name, alpine:3.20, works on an Intel server and on an Apple-silicon Mac. Here's the file that makes that possible, and the standard that every piece of an image follows.
Final project
Take a running container apart · Start one container with a memory limit and find every piece of its fence from the host: its process, its namespaces, its user and its cgroup, then predict what each piece changes.
Planned modules
Module 3: The Dockerfile and the build (next)
Which instructions make layers, the build context and .dockerignore, the build cache's rules, multi-stage builds, BuildKit (cache and secret mounts, remote caches, bake), reproducible builds, and provenance and SBOM attestations.
Module 4: Running a container well (later)
PID 1 and signals, exec form versus shell form, docker stop's grace period and --init, exit codes (128 + signal, OOMKilled), restart policies and health checks, logs and their drivers (json-file needs max-size), and ulimits.
Module 5: Data and networking (later)
Volumes versus bind mounts versus tmpfs, the bridge network and veth pairs, publishing ports through iptables or nftables, user-defined networks and the embedded DNS, host, none and macvlan, IPv6, Compose, and rootless networking.
Module 6: Limits and failures (later)
cgroup v2 first: the OOM kill in depth (memory.events), memory.high, pressure stall information, CPU weight versus quota and throttling, io.max, a JVM in a container, PIDs limits, and disk space and prune.
Module 7: Security (later)
Non-root users, capabilities, --privileged and no-new-privileges, seccomp, AppArmor and SELinux, devices, read-only filesystems, rootless mode and idmapped mounts, secrets in env and inspect, scanning, SBOMs and signing with cosign or Notation, and the Docker socket.
Module 8: Small, fast images, and Docker in your own work (later)
Distroless and Alpine trade-offs (musl versus glibc), layer ordering, multi-architecture images with buildx, an Android Gradle build in a container, Testcontainers for Kotlin tests, Docker in CI, and Docker Desktop for Mac users.
Module 9: To production (later)
Promoting an image by digest, a bridge to Kubernetes pods and CRI, debugging a running container (exec, inspect, nsenter, a debug container), a container that won't start, live restore and daemon upgrades, and rebuilding for security fixes.
How the course works
Each puzzle starts with a problem, gives you one building block, shows it in a diagram that plays itself, and ends with three questions. Every output on the page was produced on a real test machine (Docker Engine 29.9.2 on an Ubuntu 24.04 userland in a Firecracker microVM, custom kernel 6.18.44, cgroup v1) and you can reproduce it under Run it yourself. Facts come from Docker's documentation, the Linux manual pages, the kernel documentation and the Open Container Initiative specifications, quoted on every page.
Every puzzle is open from this outline. The check at the end of a puzzle unlocks its next button and saves your progress in this browser.
Take it with you
Continue with Claude
Copies a prompt that turns Claude into your tutor for this course: what you've passed, the words you know, the questions you slipped on, and how to teach you, one small block at a time. Paste it into Claude, or any AI assistant. Built in your browser from your progress; nothing is sent anywhere.
Download for Obsidian
The whole course as an Obsidian vault: a note per puzzle linked to the puzzles it builds on (open the graph view to see the building blocks), practice chapters with worked cases, a final project, a glossary, and puzzle flashcards for the Spaced Repetition plugin.