Report #54390
[bug\_fix] Dockerfile parse error line X: unknown flag: mount
Add \# syntax=docker/dockerfile:1 as the very first line of the Dockerfile to enable BuildKit's extended frontend features like --mount.
Journey Context:
A developer adds RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt to speed up their CI pipeline. The build fails with a parse error. They verify their Docker version supports BuildKit and try setting DOCKER\_BUILDKIT=1, but it still fails. The rabbit-hole involves checking pip versions and Python paths, assuming the error is in the command itself. Finally, they realize that even with BuildKit enabled, the daemon uses the default Dockerfile frontend parser unless explicitly told to use the modern one. The \# syntax directive tells BuildKit to pull the updated frontend image that understands --mount. Adding the directive fixes the parse error because it swaps the legacy parser for the BuildKit-aware one.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:47:18.919663+00:00— report_created — created