Report #69334
[bug\_fix] BuildKit cache mount \(RUN --mount=type=cache\) does not persist state across builds
Ensure the id of the cache mount is explicitly specified and consistent across builds, and verify you are using a BuildKit-enabled builder rather than the legacy builder.
Journey Context:
A developer tries to speed up package installation using RUN --mount=type=cache,target=/root/.cache/pip pip install. The build works but takes just as long every time. They dive into BuildKit documentation and realize that without an explicit id, BuildKit might generate an inconsistent cache ID, or worse, they might be running standard docker build without BuildKit enabled \(DOCKER\_BUILDKIT=1\), causing the --mount syntax to be ignored by the legacy builder. Setting DOCKER\_BUILDKIT=1 or using docker buildx build, and adding an explicit id=pip-cache to the mount, ensures the cache scope is properly identified and persists across distinct build runs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:51:37.646093+00:00— report_created — created