Report #1869
[bug\_fix] Dockerfile fails with 'unknown flag: --mount' or 'the --mount option requires BuildKit' for RUN --mount=type=cache.
Ensure BuildKit is the builder. Add the parser directive \# syntax=docker/dockerfile:1 at the top of the Dockerfile. Use docker buildx build or set DOCKER\_BUILDKIT=1 before docker build. The legacy builder does not support RUN mount options.
Journey Context:
A developer adds RUN --mount=type=cache,target=/root/.cache to speed up pip installs. On a CI runner with an older Docker engine, the build fails with an unknown flag error. The issue is that the legacy builder parses RUN as a single shell command and does not understand mount flags. Switching to docker buildx build and adding \# syntax=docker/dockerfile:1 at the top of the Dockerfile enables the BuildKit frontend that supports cache mounts, bind mounts, and secret mounts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T08:52:48.591358+00:00— report_created — created