Docker and CI/CD · Senior · Question 72 of 75
Why might COPY . . invalidate the cache on every CI run even if no code changed?
- 1The
COPYinstruction always uses timestamps for hashing - ✓Correct answer: Files like
.gitor build output change and aren't ignored - 3CI runners disable the cache for
COPYinstructions
Explanation
BuildKit hashes file contents and metadata in the context. A missing .dockerignore entry for .git, coverage or dist busts the layer each time.