The Build Cache

The build cache: why a rebuild is fast or slow, how to order a Dockerfile to keep it fast, and what it leaves on disk.

  • 7 cards
  • 3 questions
  • About 8 min
  • Intermediate to Advanced
Share

Build cache: the layers docker build keeps and reuses so that a rebuild does not repeat work. One fact explains all of it: every Dockerfile instruction leaves a layer. That fact decides whether a rebuild takes one second or twelve, why the order of two lines in a Dockerfile matters, and where tens of gigabytes of disk went. It covers layers, cache invalidation, ordering a Dockerfile for the cache, and cleaning up with docker system df and prune. It leaves out remote caches and multi-stage builds.

Contents

7 cardsnot started