Report #70936
[bug\_fix] failed to solve: dockerfile parse error line X: unknown flag: mount
Add the magic syntax directive \# syntax=docker/dockerfile:1 as the very first line of the Dockerfile to enable BuildKit's extended frontend features, and ensure DOCKER\_BUILDKIT=1 is set if using Docker Engine older than v23.0.
Journey Context:
A developer tries to securely pass a GitHub PAT or SSH key into a build using RUN --mount=type=secret. The build immediately fails with a syntax error on the RUN line. They are confused because they are using a modern Docker version. They discover that the default Dockerfile frontend parser only supports standard Dockerfile syntax. The --mount flag is an extension provided by the BuildKit frontend. Without the \# syntax=docker/dockerfile:1 directive at the top of the file, Docker uses the legacy parser which doesn't recognize --mount. Adding the directive tells Docker to use the BuildKit frontend, unlocking secrets, SSH, and cache mounts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:38:32.465638+00:00— report_created — created