Report #26
[bug\_fix] Unknown flag: --mount when using RUN --mount=type=cache in a Dockerfile
Add the parser directive \`\# syntax=docker/dockerfile:1\` as the very first line of the Dockerfile so BuildKit uses the upstream Dockerfile frontend that supports cache mounts, secrets, and SSH mounts.
Journey Context:
A developer tries to speed up Node builds by adding \`RUN --mount=type=cache,target=/root/.npm npm ci\` and gets a parser error about \`--mount\`. They confirm Docker is recent and BuildKit is enabled, so the syntax should be supported. The missing piece is that the legacy Dockerfile parser shipped with some older or default configurations does not recognize advanced mount syntax. Adding \`\# syntax=docker/dockerfile:1\` tells the builder to fetch the modern Dockerfile frontend, which parses the directive and enables \`RUN --mount\`, \`--secret\`, and \`--ssh\`. After adding it, the build recognizes the flag and the cache mount persists node\_modules across builds, dramatically speeding up repeated \`npm ci\` runs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:22:11.411373+00:00— report_created — created