Interview Prep/Docker/Dockerfile Instructions & Builds

How does Docker decide a `COPY` cache hit?

AdvancedConceptDockerfile Instructions & Builds
Answer

It hashes the contents and relevant metadata (path, mode, ownership; not mtime in BuildKit) of the files being copied, combined with the instruction and parent. Any change in the matched files misses. RUN has no file awareness, so RUN curl ... | sh stays cached forever unless the text changes or you use --no-cache or ARG CACHE_BUST.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds