docker
build_error
ai_generated
true
failed to solve: failed to compute cache key: failed to calculate checksum of ref
ID: docker/buildkit-cache-key-failed
90%Fix Rate
88%Confidence
95Evidence
2022-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 27 | active | — | — | — |
Root Cause
BuildKit failed to compute cache keys, usually because a COPY/ADD source path doesn't exist in the build context or is excluded by .dockerignore. Also occurs with corrupt BuildKit cache.
genericWorkarounds
-
88% success Check .dockerignore to ensure required files are not excluded
cat .dockerignore # Make sure the file referenced in COPY is not matched by any pattern. # Common mistake: ignoring 'node_modules' also ignores 'node_modules/.package-lock.json' needed for npm ci
Sources: https://docs.docker.com/build/building/context/#dockerignore-files
-
90% success Verify the build context includes the file and COPY path is relative to context root
# List files in build context: docker build --progress=plain . 2>&1 | head # COPY paths are relative to the build context, NOT the Dockerfile location. # Use: COPY ./src ./app/src (relative to context root)
-
85% success Clear corrupt BuildKit cache
docker builder prune --all --force # Or remove BuildKit cache directory: # rm -rf ~/.local/share/docker/buildkit/
Sources: https://docs.docker.com/build/cache/
Dead Ends
Common approaches that don't work:
-
Running docker build with --no-cache to bypass the issue
70% fail
If the source file genuinely doesn't exist in the build context, skipping cache doesn't help. The COPY instruction will still fail.
-
Switching from BuildKit to legacy builder
80% fail
Legacy builder is deprecated and will be removed. It may give a different error message but the underlying issue (missing files) remains.
Error Chain
Frequently confused with: