ERROR: BuildKit is enabled but the buildx component is missing or broken.
appeared in the test when DOCKER_BUILDKIT=1 was set for a docker
client that had no buildx plugin at all (the missing case; a broken plugin was not
tested). Install the buildx plugin for that client; on Alpine the package is
docker-cli-buildx.
In the test DOCKER_BUILDKIT=1 docker build -t fix12-dkbuild-nobx1 . failed with
exit code 1, and after apk add --no-cache docker-cli-buildx the same line with
--progress=plain added built the image. Without DOCKER_BUILDKIT=1
the client did not fail: it fell back to the legacy builder with a warning.
The error
...
+ docker buildx version
docker: unknown command: docker buildx
Run 'docker --help' for more information
...
+ DOCKER_BUILDKIT=1 docker build -t fix12-dkbuild-nobx1 .
...
ERROR: BuildKit is enabled but the buildx component is missing or broken.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/buildx/
+ echo 'exit=1'
...
This is the third probe script, after apk del docker-cli-buildx had removed the
plugin. The lines starting with + are the shell's trace of each command
(set -x). The first inner cut is the plain build shown below, the second an
exit=0 line of that earlier build that the trace printed late, and the last the
rest of the script, which printed exit=1 for this build.
Why it happens
On this client docker buildx was an unknown command. With the Alpine
docker-cli package (29.9.3-r1) installed, none of the three plugin folders the
test listed existed: /usr/libexec/docker/cli-plugins,
/usr/lib/docker/cli-plugins and /usr/local/lib/docker/cli-plugins.
With DOCKER_BUILDKIT=1 the build printed the error and stopped.
The same client without the variable printed a warning instead and built the image with the old builder:
+ docker build -t fix12-dkbuild-nobx .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/buildx/
Sending build context to Docker daemon 5.12kB
Step 1/3 : FROM alpine:latest
...
Successfully tagged fix12-dkbuild-nobx:latest
+ echo 'exit=0'
...
exit=0
...
The trace printed that build's exit=0 two lines later, after the next command.
So in the test the error appeared only when BuildKit was asked for; without the variable
the same missing plugin showed up as the legacy builder and its warning.
The fix
apk add --no-cache docker-cli-buildx > /tmp/apk2.log 2>&1
echo "apk=$?"
...
+ docker buildx version
github.com/docker/buildx v0.38.1 0dbe87f36ed472fe36b6796c3f70b4210a731fc5
+ DOCKER_BUILDKIT=1 docker build '--progress=plain' -t fix12-dkbuild-nobx1 .
#0 building with "default" instance using docker driver
...
#6 unpacking to docker.io/library/fix12-dkbuild-nobx1:latest 0.0s done
#6 DONE 0.2s
exit=0
...
The first two lines are from the second probe script; the rest is its traced output. After
the package was installed, docker buildx version answered and the build ran on
BuildKit. The Docker Desktop client on the same PC already had the plugin:
docker buildx version there printed the same v0.38.1 line. Other Linux
distributions were not tried here.
How it was reproduced
The plugin was made to be missing in a container of the test's own, created from PowerShell
with
docker run -d --name fix12-dkbuild-cli -v /var/run/docker.sock:/var/run/docker.sock -v "$lab\legacy:/src" -w /src alpine:latest sleep 1800
from the cached alpine:latest (Alpine 3.24.2), with only the Alpine
docker-cli package installed by docker exec, so the client in the
container built on the Windows machine's engine 29.9.3. Nothing on the Windows side was
changed. Three probe scripts with set -x ran in it: the first as
docker exec fix12-dkbuild-cli sh /src/probe.sh 2>&1 straight from
PowerShell (it listed the plugin folders), the second and third as
cmd /c "docker exec fix12-dkbuild-cli sh /src/probe2.sh 2>&1" and the
same with probe3.sh. The fix block is from the second, the error block and the
plain build from the third, which removed the plugin with apk del first. The
container fix12-dkbuild-cli, the folder lab\legacy mounted as
/src, the scripts and the image tags fix12-dkbuild-nobx,
-nobx0, -nobx1 and -nobx2 are the test's own.
Frequently asked
- How do I fix 'BuildKit is enabled but the buildx component is missing or broken'?
- Install the buildx plugin for the docker client you run. In the Alpine test apk add docker-cli-buildx fixed it, and docker buildx version then printed v0.38.1.
- How do I check whether buildx is installed?
- Run docker buildx version. Without the plugin the test client printed docker: unknown command: docker buildx; with it, the buildx version line.
- Why does docker build work without DOCKER_BUILDKIT=1 when buildx is missing?
- In the test the client fell back to the legacy builder, printed a DEPRECATED warning that says to install buildx, and built the image with exit code 0.
More decoded errors in the Fixes category. The legacy
builder warning on a client that has buildx, from DOCKER_BUILDKIT=0, is in
The legacy builder is deprecated.