The text file that turns the layer stack into code. How docker build packs a directory and ships it to the daemon, why instruction order is the difference between a 90-second rebuild and a 2-second one, and the instructions that decide what runs, who it runs as, and what it declares about itself — RUN, COPY, ADD, CMD, ENTRYPOINT, ARG, ENV, and the metadata that sets a container's posture.
7 topics
A Dockerfile is a recipe the daemon reads top to bottom, each instruction committing a new layer on top of the last. That makes the Dockerfile the layer stack from Chapter 2 written out as code — which is also why authoring one well is mostly about understanding what each instruction puts in a layer and when the build cache can skip it.
This chapter writes Driftwood's first Dockerfile — a naive single-stage build — and then fixes it. You will see why docker build ships a whole directory to the daemon before any instruction runs, why ordering the dependency install above the source copy turns a 90-second rebuild into a 2-second one, and how RUN, COPY, ADD, CMD, ENTRYPOINT, ARG, and ENV each behave — including the exec-vs-shell choice that decides whether your process is PID 1 and answers docker stop. The multi-stage rebuild that slims this image comes in Chapter 5; here you learn the instructions cold.