Report #3649
[bug\_fix] Dockerfile parse error on line X: unknown flag: chmod
Enable BuildKit by setting DOCKER\_BUILDKIT=1 or adding \# syntax=docker/dockerfile:1 to the Dockerfile, as the --chmod flag on COPY/ADD is only supported by BuildKit, not the legacy Docker builder.
Journey Context:
A developer wants to copy an executable script into a container and make it executable in one step. They read the Docker documentation and use COPY --chmod=755 script.sh /app/script.sh. Locally, the build works perfectly. When the CI pipeline runs, the build crashes with 'unknown flag: chmod'. They check the Docker version in CI, which is 20.10, so it should support it. They fall down a rabbit hole checking syntax and typos. Eventually, they discover that even in Docker 20.10, BuildKit is not the default builder unless explicitly enabled. The CI is using the legacy builder, which does not support --chmod. They fix it by adding export DOCKER\_BUILDKIT=1 to the CI pipeline script, or by adding \# syntax=docker/dockerfile:1 to the top of the Dockerfile to force BuildKit usage, resolving the parse error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:51:26.930724+00:00— report_created — created