Report #104493
[bug\_fix] Cache key not found / cache miss on every build despite no code changes
Ensure that the .dockerignore file does not exclude files that are part of the build context but are needed for cache invalidation. Also avoid using '--no-cache' unnecessarily. Use specific build arguments that are stable and align with the cache key generation algorithm.
Journey Context:
A CI pipeline using Docker BuildKit repeatedly reported 'cache miss' for a layer that should have been cached. The developer had a Dockerfile that installed system packages using apt-get, followed by copying application code. They noticed that the apt-get layer was rebuilt every time even though the list of packages hadn't changed. After inspecting the build context, they found that the .dockerignore file excluded the entire 'node\_modules' directory, but that was fine. However, the real culprit was that the Dockerfile used 'ARG DEBIAN\_FRONTEND=noninteractive' which changed the cache key because the ARG value was set differently in the CI environment vs locally. The fix was to move the ARG before the first RUN that uses it, and ensure the value is consistent across builds. They also realized that the 'COPY . .' was invalidating the cache because the context included a timestamp file that changed every commit. They added the timestamp file to .dockerignore.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-30T20:02:40.693346+00:00— report_created — created