Report #14611
[bug\_fix] failed to parse Dockerfile: RUN --mount=type=cache is not allowed
Add the BuildKit syntax directive \`\# syntax=docker/dockerfile:1\` as the very first line of the Dockerfile.
Journey Context:
A developer decides to optimize their CI pipeline by using BuildKit's cache mounts for package managers, adding \`RUN --mount=type=cache,target=/root/.cache/pip ...\` to their Dockerfile. They set \`DOCKER\_BUILDKIT=1\` in their environment, but the build immediately fails with a syntax error. They spend hours tweaking the mount syntax, checking Docker versions, and wondering if their BuildKit installation is broken. The rabbit hole deepens when they realize the Docker daemon supports BuildKit, but the Dockerfile parser being used is the legacy frontend, which has no idea what \`--mount\` is. The syntax directive forces the BuildKit backend to use the modern Dockerfile frontend \(shipped as an image\) that understands extended features like \`--mount\`, \`--chmod\`, and \`COPY --link\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:55:45.461132+00:00— report_created — created