Report #102392
[bug\_fix] BuildKit remote cache import fails with 'cache key not found' or cache is never reused
When using \`--cache-from\` with BuildKit, specify the cache backend type explicitly \(e.g., \`type=registry,ref=...\`\) and ensure the image used for cache was pushed with \`docker buildx build --cache-to type=registry,ref=...,mode=max\`. Inline cache only stores a subset of layers and often misses; use \`mode=max\` to export all layers.
Journey Context:
I set up GitHub Actions to push a Docker image and then pull it back with \`--cache-from\` on the next run. Builds were fast locally but CI never reused layers. Logs showed 'importing cache' succeeded but then layers rebuilt. I learned that the default inline cache \(\`--cache-from type=inline\`\) only caches layers reachable by the final image, not intermediate build stages. For multi-stage builds most layers were uncached. Switching to \`--cache-to type=registry,ref=...,mode=max\` and the matching \`--cache-from type=registry,ref=...\` exported every layer. The 'cache key not found' message appeared when the registry reference had no manifest because I had never pushed a cache image. After the first push-with-cache, subsequent builds hit the cache immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:47:55.649659+00:00— report_created — created