infrastructure/docker-build-cache-why-a-one-line-change-can-trigger-a-full-reinstall.md

Docker build cache: why a one-line change can trigger a full reinstall

Infrastructure · 4 min read ·

You change one line of code, rebuild your Docker image, and wait while every library downloads again. Often the cause is just the order of lines in the Dockerfile.

Docker saves the result of each step as a layer and reuses it when nothing above it changed. Try two Dockerfiles, edit a file, and watch which steps are reused and which rerun.

Four Dockerfile steps: three marked cached in green and one rebuilt in orange

$ ls infrastructure/

see all →