Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

A buildx_buildkit container appears during docker build and its name is already taken

Errorbuildx_buildkit_mybuilder0

Short answer

That container is the BuildKit daemon of a buildx builder that uses the docker-container driver. Its name is buildx_buildkit_ plus the builder name and node index. A name clash means an older copy was left behind, often after removing the builder with --keep-daemon. Remove the stale builder and container, or switch to the default builder.

  • Applies to Docker Engine 27, Buildx 0.2x, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the builders buildx knows about, and the BuildKit containers Docker has. The current builder is marked with a star; a container with no matching builder is the stale one.

    docker buildx ls
    docker ps -a --filter name=buildx_buildkit
  2. 2Match what you see, then jump to its fix

    1. 1docker buildx ls does not show the builder, but docker ps -a still lists buildx_buildkit_<name>0.A BuildKit container was left behind by an earlier builderFix
    2. 2docker build pulls moby/buildkit and starts a container you never asked for.A docker-container builder is the current builderFix
    3. 3A builder you recreated with the same name behaves as if it still had its old cache.A recreated builder reuses the state of the old oneFix

What does the error look like?

  • buildx_buildkit_mybuilder0
  • moby/buildkit:buildx-stable-1

Cause 1 of 3

A BuildKit container was left behind by an earlier builder

1Check

docker buildx rm has a --keep-daemon option that leaves the BuildKit daemon running after the builder is removed, so the container stays and keeps its name.

docker ps -a --filter name=buildx_buildkit --format '{{.Names}} {{.Status}}'

2Fix

Remove the stale container, then create the builder again. Remove a builder normally, without --keep-daemon, next time.

docker rm -f buildx_buildkit_mybuilder0
docker buildx create --name mybuilder --driver docker-container --use

3Verify

Run the build again; no name conflict is reported.

docker buildx build -t test-image --builder mybuilder .

Confirmed by docs.docker.com

Did this fix it?

Cause 2 of 3

A docker-container builder is the current builder

1Check

The docker-container driver runs BuildKit in its own container, and by default buildx pulls moby/buildkit for it. The default driver of docker buildx create is docker, which does not need that container.

docker buildx ls

2Fix

If you do not need multi-platform builds or cache export, switch to the default builder and remove the extra one.

docker buildx use default
docker buildx rm mybuilder

3Verify

The star in the builder list sits on default, and the build no longer starts a container.

docker buildx ls

Confirmed by docs.docker.com

Did this fix it?

Cause 3 of 3

A recreated builder reuses the state of the old one

1Check

With --keep-state the BuildKit state stays in a volume named like buildx_buildkit_<name>0_state, and a builder recreated with the same name reuses it.

docker volume ls --filter name=buildx_buildkit

2Fix

Use a new builder name, or remove the state volume if you want a clean start.

docker buildx rm mybuilder
docker volume rm buildx_buildkit_mybuilder0_state

3Verify

Create the builder again and run a build; the cache starts empty.

docker buildx create --name mybuilder --driver docker-container --bootstrap

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Remove builders with docker buildx rm and leave out --keep-daemon and --keep-state unless you need them.
  • Give each builder a clear --name instead of relying on generated names.
  • In CI, create the builder in the same job that uses it, and remove it at the end.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

A dev container port does not open in the browser when Docker runs on a remote host

If your application only accepts calls from localhost, it will reject connections from published ports

Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.