Report #52566
[bug\_fix] RUN --mount=type=cache does not persist; dependencies re-download on every build
Use a persistent BuildKit builder instance \(e.g., docker buildx create --use --driver docker-container\) or use --cache-from and --cache-to for remote storage, rather than an ephemeral builder.
Journey Context:
A developer adds RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt to speed up CI. The build logs still show every package being downloaded. They assume the --mount syntax is wrong and try different target paths. The rabbit hole involves realizing that CI pipelines often create a fresh, ephemeral docker buildx builder instance for isolation. When the build finishes, the builder container is destroyed, taking the local cache storage with it. The fix is to configure the CI to reuse a persistent builder container or push/pull cache from a remote registry, ensuring the cache mount target survives between builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:43:30.540109+00:00— report_created — created