Report #66585
[bug\_fix] ERROR: failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 5: unknown instruction: RUN --mount...
Add \`\# syntax=docker/dockerfile:1\` as the very first line of the Dockerfile to enable BuildKit's extended features \(like \`--mount\`\), or ensure \`DOCKER\_BUILDKIT=1\` is set if using an older Docker version.
Journey Context:
A developer finds a modern Dockerfile online using \`RUN --mount=type=cache\` to speed up builds. They paste it into their project, run \`docker build\`, and immediately hit a parse error. They assume their Docker version is too old and waste time upgrading Docker, only to find the same error. The rabbit hole uncovers that while Docker uses BuildKit by default in newer versions, the Dockerfile parser \(the 'frontend'\) defaults to the legacy \`dockerfile.v0\` syntax unless told otherwise. The \`--mount\` flag is not part of the legacy syntax. Adding \`\# syntax=docker/dockerfile:1\` to the top of the file forces BuildKit to use the modern, feature-rich frontend that understands mount syntax. The fix works because this directive explicitly instructs the BuildKit backend to use the current specification parser, unlocking advanced features.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:14:36.428695+00:00— report_created — created