Report #88927
[bug\_fix] failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line X: unknown flag: mount
Add \`\# syntax=docker/dockerfile:1\` at the top of the Dockerfile, or ensure \`DOCKER\_BUILDKIT=1\` is set if using an older Docker version. The root cause is that the legacy Docker builder does not support the \`--mount\` flag; it requires BuildKit and the explicit frontend syntax directive to enable the extended Dockerfile features.
Journey Context:
A developer is trying to optimize their CI pipeline by caching npm or pip packages using \`RUN --mount=type=cache\`. They add the flag to their Dockerfile, but the build immediately fails with an 'unknown flag: mount' error. They spend hours tweaking the cache target path and checking Docker documentation, assuming it's a syntax error in the mount parameters. They eventually realize that while Docker has BuildKit enabled by default in newer versions, their CI environment is running an older Docker version \(like 19.03\) where BuildKit isn't the default, or the Dockerfile parser is falling back to the legacy builder. By adding the \`\# syntax=docker/dockerfile:1\` directive at the very first line of the Dockerfile, they force the use of the BuildKit frontend, which parses the \`--mount\` flag correctly. This works because the syntax directive explicitly pulls the BuildKit frontend image to evaluate the Dockerfile, bypassing the legacy builder entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:51:02.537244+00:00— report_created — created