Module 01 · DevOps · Containers & Docker · about 17 min to read
Continue where you left off ×
The Recipe (the Dockerfile)
The Recipe · Open board
The same board, now the file that writes the recipe: one line, one layer, and the order is the whole game.
Before you start. You’ve already built an image and watched a container start from it: that image is a stack of layers, frozen once each one is written. This lesson is about the file that writes those layers down, and the habit that decides whether your next build takes three seconds or three minutes.
The idea in 30 seconds
A Dockerfile is a recipe: docker build runs it top to bottom, and every instruction that touches the filesystem becomes one layer.
Rebuild with nothing changed and Docker reuses layers instead of rebuilding them, the cache, the same trick Feldman built into Make in 1976 to stop recompiling files nobody had touched.
A layer is a hit or a miss, and cache validity is positional: the first miss, and everything below it, rebuilds. A hit is never re-checked.
Order instructions least-often-changing first: dependency install first, your own code last, so an edit stops costing you the install.
COPY hashes the bytes it’s copying, RUN hashes the command’s literal text, the cache key, and why touch doesn’t bust a cache and apt-get update alone never reruns.
Read the story
Lesson 6 of 70 in DevOps
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson 1976: a morning wasted, because nothing said what had changed The click: a Dockerfile skips work the same way, one line at a time The second build: skip what hasn’t changed, in order COPY checks the bytes, RUN checks the words The instructions you’ll actually use The build context: everything in the folder, before anything starts Multi-stage: build heavy, ship light Layers are append-only: what a deleted file actually costs you CMD and ENTRYPOINT: the line that decides your shutdown behaviour Terms it explains: layer, cache, hit, miss, 4.96 s, 0.72 s, cache key, FROM, WORKDIR, COPY, RUN, CMD / ENTRYPOINT, history entry, build context, `ENTRYPOINT`, `CMD`.
Review DevOps
Mark as read Saved in this browser, and to your account when you sign in.