Report #15593
[bug\_fix] BuildKit RUN --mount=type=cache not persisting across CI runs
Configure the CI workflow to use external cache storage \(e.g., type=gha or type=registry\) via cache-from and cache-to flags, or use a persistent BuildKit daemon. Cache mounts only persist on the daemon's local filesystem.
Journey Context:
A developer adds RUN --mount=type=cache,target=/root/.cache/pip install -r requirements.txt to speed up builds. Locally, it works perfectly and subsequent builds are instant. In GitHub Actions, the build takes just as long as before. They spend hours checking if the mount syntax is correct, adding id=... and sharing=locked, but nothing works. The rabbit hole leads them to realize that GitHub Actions uses an ephemeral Docker daemon \(docker-container driver\) that is destroyed after the job. The local cache mount is destroyed with it. The fix is to use GitHub Actions cache backend by passing --cache-to type=gha --cache-from type=gha to the buildx command, which persists the layer cache externally, allowing the mount cache to be restored from the saved layers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:28:17.963833+00:00— report_created — created