Report #94535
[bug\_fix] Dockerfile parse error line X: unknown instruction: RUN \(when using --mount=type=cache\)
Add the magic syntax directive \`\# syntax=docker/dockerfile:1\` to the very first line of the Dockerfile.
Journey Context:
A developer adds \`RUN --mount=type=cache,target=/root/.cache pip install -r requirements.txt\` to speed up Python dependency installation. The build immediately fails with a syntax error pointing at the RUN line. They check the Dockerfile syntax over and over, assuming a typo. They rewrite the mount syntax, but it still fails. After checking BuildKit documentation, they realize the default Docker builder frontend only understands standard Dockerfile instructions. The \`--mount\` flag is a BuildKit extension. Without the syntax directive at the very first line of the Dockerfile, the builder doesn't know to use the extended frontend capable of parsing the mount syntax. Adding the directive tells BuildKit to use the extended frontend, resolving the parse error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:15:41.591891+00:00— report_created — created