Report #66403
[bug\_fix] Dockerfile parse error line 5: unknown flag: mount
Add the BuildKit syntax directive \`\# syntax=docker/dockerfile:1\` as the very first line of the Dockerfile.
Journey Context:
A developer writes a Dockerfile using \`RUN --mount=type=cache\` after reading modern Docker documentation. They run \`docker build .\` and immediately hit a parse error claiming the \`mount\` flag is unknown. They verify their Docker version is recent and even export \`DOCKER\_BUILDKIT=1\`, but the error persists. The rabbit hole involves checking Docker engine compatibility and BuildKit setup. The root cause is that while BuildKit is enabled, the default frontend bundled with the Docker daemon uses an older Dockerfile syntax that doesn't support \`--mount\`. The magic syntax directive tells BuildKit to automatically pull and use the latest Dockerfile frontend image from Docker Hub, which understands the advanced features, bypassing the daemon's built-in parser.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:56:26.659632+00:00— report_created — created