Report #2622
[bug\_fix] BuildKit reports \`failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line X: unknown instruction\`
Add a syntax directive at the top of the Dockerfile, e.g., \`\# syntax=docker/dockerfile:1\`, and ensure Docker/BuildKit is new enough to support the instruction. The root cause is that newer Dockerfile features \(such as \`RUN --mount\`, \`COPY --link\`, or heredocs\) require a frontend newer than the one installed or pinned; without an explicit syntax directive the daemon falls back to its built-in parser, which may not recognize the feature.
Journey Context:
You paste a Dockerfile using \`RUN --mount=type=cache,target=/root/.cache\` to speed up package installs. The local build on an older Docker Engine fails with \`unknown instruction: RUN --mount\`. You think the syntax is wrong and try different quoting. A colleague points out that \`--mount\` requires BuildKit and the Dockerfile syntax directive. Adding \`\# syntax=docker/dockerfile:1\` as the first line forces the build to use the latest frontend, and the parse error disappears. On an even older host without BuildKit, the same directive triggers an explicit error telling you to enable BuildKit instead of a confusing parse failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T13:28:49.196859+00:00— report_created — created