Writing a DockerfileThe instruction order that keeps builds fast and images small.ComputingEach instruction is a cached layer; a change invalidates it and everythingafter it.1Pin the base imageFROM node:22-alpine, not node:latest. Reproducibility mattersmore than freshness.2Copy the manifests onlyCOPY package*.json ./ then install. Dependencies re-install onlywhen they change.3Then copy the sourceCOPY . . after installing, so a code change does not re-run theinstall.4Use multi-stage buildsBuild in one stage, copy only the artefacts into a slim runtimestage.5Run as a non-root userUSER node. Root inside a container is a real risk.ALSO.dockerignore for node_modules and .gitOne process per containerPrefer COPY over ADDCopying source before installing dependencies is the single mostcommon cause of slow Docker builds.Writing a Dockerfilelearnposters.com
Writing a Dockerfile — printable computing wall chart from LearnPosters. Free vector PDF, US Letter and A4.

Writing a Dockerfile, step by step

Each instruction is a cached layer; a change invalidates it and everything after it.

  1. Pin the base imageFROM node:22-alpine, not node:latest. Reproducibility matters more than freshness.
  2. Copy the manifests onlyCOPY package*.json ./ then install. Dependencies re-install only when they change.
  3. Then copy the sourceCOPY . . after installing, so a code change does not re-run the install.
  4. Use multi-stage buildsBuild in one stage, copy only the artefacts into a slim runtime stage.
  5. Run as a non-root userUSER node. Root inside a container is a real risk.

Also

  • .dockerignore for node_modules and .git
  • One process per container
  • Prefer COPY over ADD

Copying source before installing dependencies is the single most common cause of slow Docker builds.

Questions about the Writing a Dockerfile poster

What’s on the Writing a Dockerfile poster?
5 numbered steps, with a full worked run-through. Each instruction is a cached layer; a change invalidates it and everything after it. Pin the base image — FROM node:22-alpine, not node:latest. Reproducibility matters mo…; Copy the manifests only — COPY package*.json ./ then install. Dependencies re-install…; Then copy the source — COPY . . after installing, so a code change does not re-run th…; Use multi-stage builds — Build in one stage, copy only the artefacts into a slim runt…; Run as a non-root user — USER node. Root inside a container is a real risk.. Copying source before installing dependencies is the single most common cause of slow Docker builds.
Who is the Writing a Dockerfile poster for?
Writing a Dockerfile belongs to the Computing section rather than to a school year, because computing is not something one grade owns. Anyone learning tools can pin it up — a beginner, a student mid-course, or someone revising years later.
When should you use the Writing a Dockerfile poster?
Order the layers from least to most frequently changing. That is the whole caching strategy. A wall chart earns its place by being glanceable from where the work is happening, so Writing a Dockerfile belongs on the wall where that computing work actually happens, within glancing distance, rather than filed away.
What other posters go with Writing a Dockerfile?
Code Review, Debugging Method and Docker Basics sit alongside Writing a Dockerfile in the Computing section. Printed together they make a wall rather than a single sheet, which is how a reference set actually gets used.Code ReviewDebugging MethodDocker Basics
Is the Writing a Dockerfile poster free to download and print?
Yes. Writing a Dockerfile downloads as a free PDF with no account, no email and no watermark, like everything else in the Computing section. Print as many copies as you like for a home, a classroom, a library or a tutoring group; reselling the file is the only thing the licence rules out.Read the licence
What size does the Writing a Dockerfile poster print at?
Writing a Dockerfile is a vector PDF laid out for US Letter, and prints on A4 with Fit to page — the same file, no separate download. Because every mark on it is drawn rather than photographed, it stays sharp enlarged to A3, A2 or A1 at a copy shop. Colour carries emphasis only, so a greyscale print of Writing a Dockerfile loses nothing.Printing guide

Related posters

Charts that sit alongside Writing a Dockerfile on the same wall.

Browse every Computing poster, or start from the full catalogue.