Card 07/ 07
Recap: The Build Cache
Layers, the chain of invalidation, the ordering that keeps installs cached, and cleaning up, with where each was.
The build cache comes down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| Each instruction leaves a layer, the unit of both caching and disk | Image Layers and the Build Cache |
CACHED on a build line means the layer was reused and cost nothing | Build Cache Example: The Same Build, Run Twice |
| The cache is a chain: once a layer changes, everything below it runs again | Cache Invalidation: One Source Edit Reinstalls Every Dependency |
| Copy the dependency list, install, then copy the source | Ordering a Dockerfile So the Dependency Install Stays Cached |
docker system df shows what is reclaimable; prune --volumes can delete a database | Disk Usage Example: docker system df and docker system prune |
Put together: order the Dockerfile so the slow, stable steps come first, and clean up what the cache leaves behind with a look at docker system df before any prune.
← → move through sections and cards