Report #92103
[bug\_fix] RUN --mount=type=cache not persisting across CI builds \(cache key not found / empty cache\)
Configure the CI builder to use an external cache storage \(like \`type=gha\` or \`type=s3\`\) using \`--cache-to\` and \`--cache-from\` flags, or ensure the BuildKit daemon's state directory is persisted between CI runs.
Journey Context:
A developer adds \`RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt\` to speed up builds. Locally, it works perfectly and the second build is instant. In GitHub Actions, it is always slow. They dive into the BuildKit documentation, suspecting a bug with cache mounts. They discover that \`--mount=type=cache\` only persists cache on the local BuildKit daemon's storage. Because GitHub Actions uses ephemeral runners, the Docker daemon and its cache are destroyed after every job. The cache mount appears empty every time. The fix works because explicitly exporting the cache to GitHub Actions' native cache backend \(\`type=gha\`\) or an S3 bucket persists the build state across runs, allowing the cache mount to be hydrated on subsequent builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:11:13.910702+00:00— report_created — created