Dockerfile "the --chmod option requires BuildKit" in CI
The build used the legacy builder, which does not support COPY --chmod. The flag requires BuildKit, so the build fails until BuildKit is enabled or the flag is removed.
What this error means
docker build fails with "the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled" when DOCKER_BUILDKIT=0.
the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/
to learn how to build images with BuildKit enabledCommon causes
BuildKit is disabled in CI
An environment with DOCKER_BUILDKIT=0, or an old default, uses the legacy builder that does not accept --chmod.
A BuildKit-only feature on the classic builder
COPY --chmod is a BuildKit feature; the legacy builder rejects it even though --chown is accepted.
How to fix it
Enable BuildKit
Turn on BuildKit so the --chmod flag is supported.
DOCKER_BUILDKIT=1 docker build -t app .Set the mode in a separate RUN
If you must use the legacy builder, copy first and then chmod.
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod 755 /app/entrypoint.shHow to prevent it
- Enable BuildKit for builds that use
--chmod. - Avoid setting
DOCKER_BUILDKIT=0unless required. - Fall back to a separate RUN chmod on the legacy builder.