Report #4429
[bug\_fix] failed to solve: failed to parse dockerfile: unknown flag: mount \(or unknown flag: security\)
Add the BuildKit syntax directive as the very first line of the Dockerfile: \`\# syntax=docker/dockerfile:1\`. This opts the build into the current Dockerfile frontend and enables \`RUN --mount\`, \`--security=insecure\`, and other modern features.
Journey Context:
A developer writes \`RUN --mount=type=cache,target=/go/pkg/mod go mod download\` and runs \`docker build .\`. The legacy builder fails with "unknown flag: mount". They verify their Docker version supports BuildKit and learn that the default Dockerfile parser only enables advanced flags when the Dockerfile explicitly declares a modern syntax frontend. They add \`\# syntax=docker/dockerfile:1\` as the first line and rerun the build. BuildKit now parses the mount flag correctly and caches Go modules between builds. They realize the directive is a named frontend image reference, not a comment, and must be on line one. They add it to their project's Dockerfile template so every future image starts in BuildKit mode.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:28:34.334681+00:00— report_created — created