Report #17831
[bug\_fix] failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line X: unknown flag: mount
Add \`\# syntax=docker/dockerfile:1\` to the very first line of the Dockerfile to enable BuildKit's extended frontend features.
Journey Context:
A developer switches to Docker BuildKit to speed up builds and adds \`RUN --mount=type=cache,target=/root/.npm npm install\` to cache npm packages. The build immediately fails with a parse error. They double-check the Docker documentation and the syntax is correct. They try escaping the command, using different shells, and reinstalling Docker, but the error persists. The rabbit hole deepens as they assume it is a bug in their Docker version. Finally, they realize that while \`DOCKER\_BUILDKIT=1\` enables the BuildKit backend, the Dockerfile parser \(the frontend\) still defaults to the legacy Dockerfile syntax unless explicitly told to use the new one. Adding the magic syntax directive tells BuildKit to use the modern frontend that understands \`--mount\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:27:23.523674+00:00— report_created — created