Report #51641
[bug\_fix] dockerfile parse error on line X: unknown instruction: RUN--MOUNT
Add the BuildKit syntax directive \`\# syntax=docker/dockerfile:1\` to the very first line of the Dockerfile, and ensure BuildKit is enabled \(set \`DOCKER\_BUILDKIT=1\` if using older Docker versions\).
Journey Context:
A developer finds a Dockerfile snippet online that uses \`RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt\` to speed up dependency installation. When they build, it fails with a parse error. They assume the syntax is invalid or their Docker version is too old. They try updating Docker, but the error persists. The rabbit hole leads them to discover that the default legacy builder in older Docker versions doesn't understand the \`--mount\` flag. Even in newer versions, if the Dockerfile doesn't explicitly request the BuildKit frontend, it might default to the legacy parser. Adding the \`\# syntax=docker/dockerfile:1\` directive tells Docker to use the BuildKit frontend, which parses the extended RUN --mount syntax correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:10:22.667212+00:00— report_created — created