Report #56946
[bug\_fix] BuildKit cache mount \(\`RUN --mount=type=cache\`\) does not persist across builds in CI, causing full dependency re-downloads.
Use \`docker buildx build\` with \`--cache-to\` and \`--cache-from\` to persist cache to a registry or local directory, or avoid recreating the buildx builder instance on every CI run.
Journey Context:
A developer implements \`RUN --mount=type=cache,target=/root/.cache/pip ...\` in their Dockerfile. Locally, builds are lightning-fast as the pip cache persists. However, in their GitHub Actions CI pipeline, the cache is ignored and dependencies download from scratch every time. They discover their CI script runs \`docker buildx create --use\` at the start of every job, creating an ephemeral \`docker-container\` driver that is destroyed at the end of the job, taking the local BuildKit cache with it. They fix it by configuring the CI to use the default \`docker\` driver \(which stores cache on the host\) or by utilizing BuildKit's cache export features \(\`--cache-to=type=local,dest=/path\`\) to save and restore the cache via GitHub Actions caching.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:04:30.695454+00:00— report_created — created