Report #42305
[bug\_fix] dockerfile parse error line X: unknown instruction: RUN \(when using BuildKit mount syntax\)
Add the BuildKit syntax directive \# syntax=docker/dockerfile:1 as the very first line of the Dockerfile to enable BuildKit's extended frontend features.
Journey Context:
A developer writes a Dockerfile using RUN --mount=type=cache,target=/root/.npm npm install. It builds flawlessly on their local machine running Docker Desktop. When pushed to CI, the build fails with a parse error on the RUN instruction. They debug by comparing Docker versions and discover the CI runner uses an older Docker version where BuildKit is not the default builder. Without the syntax directive, the legacy builder attempts to parse the file and fails because it doesn't understand mount syntax. Adding \# syntax=docker/dockerfile:1 at the top fixes it because it instructs the Docker CLI to use BuildKit's frontend parser, automatically enabling the extended syntax even on older daemons that support BuildKit.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:28:47.514531+00:00— report_created — created