Docker "the --mount option requires BuildKit" - Enable BuildKit in CI
Your Dockerfile uses BuildKit-only syntax (RUN --mount=...) but the build ran with the legacy builder, which does not understand it.
What this error means
The build fails on the first RUN --mount=... line with the --mount option requires BuildKit. The same Dockerfile builds fine on a machine where BuildKit is the default.
the --mount 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 on this runner
Older Docker, or an environment with DOCKER_BUILDKIT=0, falls back to the legacy builder. Cache/secret/ssh mounts are BuildKit features and are rejected.
Building through a path that bypasses BuildKit
Some tools or wrappers invoke the legacy build API even on a host that could use BuildKit, so the mount syntax is not recognized.
How to fix it
Enable BuildKit explicitly
Turn BuildKit on via the environment variable for the build.
DOCKER_BUILDKIT=1 docker build .
# or set it for the whole job
export DOCKER_BUILDKIT=1Use buildx for consistent BuildKit behavior
In GitHub Actions, set up buildx so BuildKit is always the builder.
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
push: falseHow to prevent it
- Set
DOCKER_BUILDKIT=1(or use buildx) in any pipeline using mount syntax. - Pin a Docker version where BuildKit is the default.
- Document the BuildKit requirement next to the Dockerfile.