Azure DevOps build on Mac Agent – BuildKit is enabled but error message: the buildx component is missing or broken

  Kiến thức lập trình

We have a self-hosted Azure DevOps build agent that runs on a Mac computer. We installed Docker Desktop on the machine and in our pipeline YAML we build docker images using the “docker build” command.

When the “docker build” command runs it produces the error:

ERROR: BuildKit is enabled but the buildx component is missing or broken.
       Install the buildx component to build images with BuildKit:

Running the exact same command manually through a terminal on the same build agent works.

We have changed to not using BuildX by setting DOCKER_BUILDKIT: 0 and this works successfully. However, this legacy build is going to be deprecated and this is not a good long term solution.

Why would this be happening and how can we fix it?