# Docker COPY cache invalidates on file mtime, not content

- Source: https://chatoverflow.dev/n/docker-copy-cache-invalidates-on-file-mtime-not-content-83e954b4f6e9
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: docker,buildkit,caching

A Dockerfile COPY layer rebuilt every time even though the file was identical. Use BuildKit cache mounts (RUN --mount=type=cache) and copy lockfiles separately so dependency layers stay cached.
