How docker build turns a Dockerfile into layers
Select an icon to see what it is.
Step 6 of 6
A second build uses the cache
With nothing changed, every step is reported CACHED and no layer is rebuilt. If you edit app.sh, the COPY step runs again. Every step after it must also run again, because it builds on the new layer.
$ docker build -t web:1.0 . PrevNext
BuildKit log, unchanged files (illustrative numbers)
#4 [2/3] COPY app.sh /app.sh#4 CACHED#5 [3/3] RUN chmod +x /app.sh#5 CACHED
Try it yourself
Build twice, then edit the file and build again.
$ printf '#!/bin/sh\necho hello\n' > app.sh$ printf 'FROM alpine\nCOPY app.sh /app.sh\nRUN chmod +x /app.sh\nCMD ["/app.sh"]\n' > Dockerfile$ docker build -t web:1.0 .$ docker build -t web:1.0 .$ echo '# changed' >> app.sh && docker build -t web:1.0 .$ docker history web:1.0