Report #96722
[bug\_fix] Package manager cache \(like pip or npm\) mounted via --mount=type=cache causes bizarre dependency conflicts or 'cache key not found' errors across different projects or branches.
Specify an explicit id parameter in the mount directive \(e.g., --mount=type=cache,id=myproject-npm,target=/root/.npm\) to namespace the cache.
Journey Context:
A developer uses BuildKit's --mount=type=cache,target=/root/.cache/pip to speed up pip installs across multiple microservices. Suddenly, builds start failing with weird dependency resolution errors, or pulling the wrong package versions. They clear the Docker build cache \(docker builder prune\) and it works once, then fails again. They realize that because they didn't specify an id, BuildKit defaults the cache ID to the target path \(/root/.cache/pip\). Since multiple different projects use the exact same target path, they all share the exact same cache directory on the host, leading to conflicting metadata and corrupted caches. Adding a unique id isolates the cache per project.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:55:54.243842+00:00— report_created — created