BUILDKIT_CACHE_KEY_ERROR
cicd
build_error
ai_generated
true
错误:无法解析:计算缓存键失败:无法计算引用的校验和...:未找到
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref ...: not found
ID: cicd/docker-buildkit-export-failed
82%修复率
88%置信度
1证据数
2023-08-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.5 | active | — | — | — |
| BuildKit 0.12.2 | active | — | — | — |
| Ubuntu 22.04 | active | — | — | — |
根因分析
Docker BuildKit 缓存导出失败,因为引用的缓存层丢失或损坏,通常是由于并发构建覆盖了相同的缓存或缓存上传不完整。
English
Docker BuildKit cache export fails because the referenced cache layer is missing or corrupted, often due to concurrent builds overwriting the same cache or incomplete cache uploads.
官方文档
https://docs.docker.com/build/cache/解决方案
-
Invalidate the specific cache key by adding a unique build argument: docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from type=registry,ref=mycache --cache-to type=registry,ref=mycache,mode=max .
-
Use a unique cache tag per build (e.g., cache-<commit-sha>) to avoid collision: docker build --cache-from type=registry,ref=myrepo/cache:${GITHUB_SHA} --cache-to type=registry,ref=myrepo/cache:${GITHUB_SHA} . -
Clear the remote cache entirely: docker buildx rm mybuilder; docker buildx create --use --driver-opt network=host; then rebuild with fresh cache export.
无效尝试
常见但无效的做法:
-
Rebuilding the entire Docker image without cache (--no-cache)
50% 失败
While this bypasses the cache key error, it defeats the purpose of caching and significantly increases build time; the underlying cache corruption is not fixed.
-
Manually deleting all Docker cache directories on the runner
80% 失败
Cache may be stored externally (e.g., on a registry or S3); local deletion doesn't fix remote cache corruption.
-
Increasing the build timeout
95% 失败
The error is not timeout-related; it's a cache integrity issue.