Skip to content
Latchkey

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.

docker build
the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/
to learn how to build images with BuildKit enabled

Common 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.

Terminal
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.

Dockerfile
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod 755 /app/entrypoint.sh

How to prevent it

  • Enable BuildKit for builds that use --chmod.
  • Avoid setting DOCKER_BUILDKIT=0 unless required.
  • Fall back to a separate RUN chmod on the legacy builder.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →