Report #31445
[bug\_fix] cache key not found when using --cache-from and --cache-to in CI
Add the \`mode=max\` parameter to the \`--cache-to\` export \(e.g., \`--cache-to=type=registry,ref=image:cache,mode=max\`\) to ensure all intermediate layers are exported, not just the final image.
Journey Context:
A developer sets up a CI pipeline with \`docker buildx build --cache-to=type=registry,ref=myimage:cache --cache-from=type=registry,ref=myimage:cache ...\`. The first run pushes the cache. The second run fails to find the cache keys for intermediate steps, re-running them. They dig into BuildKit cache manifests. They discover that by default, \`type=registry\` cache only stores the cache for the final image \(min mode\). Intermediate layers \(like the dependency install\) are lost. Adding \`mode=max\` to \`--cache-to\` tells BuildKit to export all intermediate layer caches to the registry manifest, allowing \`--cache-from\` to find and reuse them.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T07:10:01.569345+00:00— report_created — created