Report #45382
[bug\_fix] COPY --chmod results in a syntax error: unknown flag: chmod
Add \`\# syntax=docker/dockerfile:1\` at the very top of the Dockerfile to enable BuildKit frontend features, or ensure \`DOCKER\_BUILDKIT=1\` is enabled.
Journey Context:
A developer tries to use the \`COPY --chmod\` feature to set file permissions in a single step, avoiding a separate \`RUN chmod\` layer. The build fails with an 'unknown flag: chmod' error. They are confused because the official Docker documentation says \`--chmod\` is supported. The problem is that \`--chmod\` is a BuildKit-only feature, introduced in the Dockerfile frontend v1.3. Older Docker versions or builds without BuildKit use the legacy builder, which doesn't support it. Even with BuildKit enabled, the default frontend might default to an older syntax version. Adding the \`\# syntax=docker/dockerfile:1\` magic comment forces BuildKit to use the latest frontend, unlocking the \`--chmod\` flag. The fix works because the syntax comment tells BuildKit to pull and use the modern Dockerfile parser that understands the new flags.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:38:39.359906+00:00— report_created — created