Report #11678
[bug\_fix] BuildKit cache not reused between builds: WARNING: No cache manifest for , skipping cache import
Ensure both \`--cache-to\` and \`--cache-from\` are specified with the same reference. On the first build, use \`--cache-to=type=registry,ref=,mode=max\` to export full cache metadata. On subsequent builds, add \`--cache-from=type=registry,ref=\` to import it. The \`mode=max\` flag is critical — without it, only the final layer's cache is exported, not intermediate layers.
Journey Context:
A CI/CD pipeline runs \`docker build --cache-from=myapp:cache .\` but always gets 'No cache manifest' and rebuilds from scratch. The developer assumes cache-from is broken. They read the docs and realize that cache-from only imports cache that was previously exported with cache-to. They were pushing the image with \`docker push\` but never exporting BuildKit's cache metadata separately. The fix is to add \`--cache-to=type=registry,ref=myapp:cache,mode=max\` on every build \(including the first one, where it creates the cache manifest\), and \`--cache-from=type=registry,ref=myapp:cache\` on subsequent builds. The \`mode=max\` is essential because the default \`mode=min\` only exports cache for the final image layers, not intermediate build stages — so multi-stage builds would still miss most cache hits. After this change, the CI pipeline goes from 8-minute builds to 30-second builds when dependencies have not changed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:55:10.921293+00:00— report_created — created