Report #11294
[bug\_fix] Dockerfile parse error: unknown instruction: RUN --mount=type=cache
Add the BuildKit syntax directive \`\# syntax=docker/dockerfile:1\` as the very first line of the Dockerfile to enable the BuildKit frontend features required for \`--mount\`.
Journey Context:
A developer tries to optimize their CI pipeline by using BuildKit's cache mount feature: \`RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt\`. The build instantly fails with a parse error. They assume their Docker version is outdated and waste hours updating the Docker daemon and CLI on the CI runner. The version is fine, but the error persists. They try setting \`DOCKER\_BUILDKIT=1\` as an environment variable, but the parse error remains. The rabbit hole ends when they realize that even with BuildKit enabled, the Dockerfile parser defaults to the legacy syntax unless explicitly told otherwise. The \`--mount\` flag is not part of the legacy Dockerfile specification. Adding \`\# syntax=docker/dockerfile:1\` to line 1 instructs BuildKit to use the modern frontend, instantly resolving the parse error and unlocking the cache mount feature.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:55:21.303976+00:00— report_created — created