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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://docs.docker.com/build/cache/

解决方案

  1. 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 .
  2. 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} .
  3. Clear the remote cache entirely: docker buildx rm mybuilder; docker buildx create --use --driver-opt network=host; then rebuild with fresh cache export.

无效尝试

常见但无效的做法:

  1. 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.

  2. 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.

  3. Increasing the build timeout 95% 失败

    The error is not timeout-related; it's a cache integrity issue.