Report #780
[bug\_fix] \`--mount=type=cache,target=/root/.cache\` appears empty on every build, so packages are re-downloaded each time.
Cache mounts are local to the BuildKit worker and are not exported by default. For persistence across CI jobs, export and import cache explicitly with \`--cache-to type=local,dest=...\` and \`--cache-from type=local,src=...\`, or use a registry/GHA cache backend. Ensure the same builder is reused for local iterations.
Journey Context:
A developer adds \`RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get install -y ...\` expecting apt packages to persist across CI runs. Instead, every CI job re-downloads packages because cache mounts live in the BuildKit worker's filesystem and are not serialized into the image or automatically exported. After reading the cache-mount documentation, they add \`--cache-to type=gha\` on GitHub Actions and \`--cache-from type=gha\` on subsequent runs, separating the cache-mount optimization for local builds from the exported cache used in CI.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T12:56:35.200598+00:00— report_created — created