Report #84114
[bug\_fix] RUN --mount=type=cache does not persist package manager caches across builds, resulting in slow builds
Assign a specific, stable id to the cache mount \(e.g., --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store\) and ensure BuildKit is enabled.
Journey Context:
A developer adds RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt to speed up builds. It works locally but in CI, the cache is never hit. They dig into the BuildKit cache export features, trying --cache-from and --cache-to, which adds complexity but doesn't help. The root cause is that without an explicit id, BuildKit generates a default ID based on the target path, which can sometimes collide or fail to persist properly in certain CI daemon configurations. Adding an explicit id ensures BuildKit identifies and reuses the exact same cache volume across builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:46:38.593741+00:00— report_created — created