Card 07/ 07

RecapDifficulty: Advanced1 min

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.

What the topic established, and which card it was on
The ideaWhere
Each instruction leaves a layer, the unit of both caching and diskImage Layers and the Build Cache
CACHED on a build line means the layer was reused and cost nothingBuild Cache Example: The Same Build, Run Twice
The cache is a chain: once a layer changes, everything below it runs againCache Invalidation: One Source Edit Reinstalls Every Dependency
Copy the dependency list, install, then copy the sourceOrdering a Dockerfile So the Dependency Install Stays Cached
docker system df shows what is reclaimable; prune --volumes can delete a databaseDisk 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.