Report #79726
[bug\_fix] Dockerfile parse error line X: Unknown flag: mount
Add the BuildKit syntax directive \`\# syntax=docker/dockerfile:1\` as the very first line of the Dockerfile, or explicitly enable BuildKit by setting \`DOCKER\_BUILDKIT=1\` in the build environment.
Journey Context:
A developer discovers the \`RUN --mount=type=cache\` instruction to speed up package installations and adds it to their Dockerfile. Locally, it works fine because Docker Desktop defaults to BuildKit. When they push to CI \(e.g., an older Jenkins runner or GitHub Actions using an outdated action\), the build fails with 'Unknown flag: mount'. They assume the Docker version in CI is too old and waste time trying to upgrade the CI runner. The actual root cause is that the legacy Docker builder does not understand the \`--mount\` flag. The legacy builder ignores the \`\# syntax\` directive if it isn't the very first line, or defaults to the legacy parser if the directive is missing entirely. Adding the directive forces the Docker CLI to pull the BuildKit frontend image and parse the Dockerfile using BuildKit capabilities, even if the daemon version is slightly older, instantly resolving the syntax error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:25:29.802476+00:00— report_created — created