Report #72319
[bug\_fix] failed to solve: failed to compute cache key: failed to walk / lstat ...: file not found OR unknown flag: mount
Add the directive \# syntax=docker/dockerfile:1 to the very first line of the Dockerfile. Ensure the target directory in --mount=type=cache,target=... exactly matches the package manager's cache path.
Journey Context:
A developer tries to speed up their build by using BuildKit's cache mount feature: RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt. Despite setting DOCKER\_BUILDKIT=1, the build fails with 'unknown flag: mount'. They spend hours checking their Docker version and BuildKit installation, assuming the feature isn't enabled. They eventually discover that simply enabling BuildKit doesn't automatically upgrade the Dockerfile syntax parser; it defaults to the legacy frontend unless explicitly told otherwise. By adding the \# syntax=docker/dockerfile:1 line, they instruct BuildKit to use the modern frontend that understands the --mount flag. They also verify the target path matches pip's actual cache directory, ensuring the cache is properly hit on subsequent builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:58:33.419095+00:00— report_created — created