19/40
docker run: The Full Picture
In one sentence: One command composes everything from Parts 1–3: resolve the image (pull if needed), mount an overlay, allocate a network, then hand a bundle down the runtime chain — in an order where each step's output is the next step's input.
You already know
- Lesson 15: pull = manifest → diff → fetch missing. Lesson 9: overlay = lowers + fresh upper.
- Lesson 3: daemon → manager → shim → runtime → kernel. Lesson 18: create, then start.
Everything, in dependency order
This is the course's midpoint summit — no new concepts, only composition. The order is forced by data dependencies: you can't mount layers you don't have, can't write a runtime bundle without a mounted rootfs and a network to reference, can't start what isn't created. Each lesson you've done is one arrow:
flowchart TB A["1· resolve image
(reference store; pull if missing — L15)"] B["2· mount overlay
(image lowers + new upper — L9)"] C["3· allocate network
(sandbox + IP — Part 6)"] D["4· write bundle
(rootfs path + config: cmd, env, limits)"] E["5· runtime chain
(manager → shim → runc — L3)"] F["6· kernel setup
(namespaces L4, cgroups L5, seccomp L6)"] G["7· exec app — state: Running (L18)"] A --> B --> D C --> D D --> E --> F --> G
sequenceDiagram
participant CLI as CLI
participant D as Daemon
participant N as Net allocator
participant M as Manager
participant S as Shim
participant R as Runtime
CLI->>D: run api:2.2
D->>D: resolve tag; layers present? (else pull)
D->>D: mount overlay: lowers + fresh upper
D->>N: create sandbox, assign IP
N-->>D: eth0 ready
D->>M: create container (bundle)
M->>S: spawn shim
S->>R: create: namespaces, cgroups, filters
R->>R: exec app; runtime exits
S-->>M: running (pid)
M-->>D: started
D-->>CLI: container id, attached stream
Anchor these
- run = resolve → mount → network → bundle → chain → kernel → exec. The order is data-forced.
- The bundle (rootfs + config file) is the only thing the runtime ever sees — full decoupling.
- No step here is new — the command is Parts 1–3 composed.
Next step
See what actually stuck.
Take the practice scenarios now.