Docker compose Confilct default container name already in use

I am using docker-compose version 2.17.2 on linux ubuntu and I get this error Message:

“Error response from daemon: Conflict. The container name “/buildx_buildkit_default” is already in use by container “eadcc8e7164bf66380fa38e3ef82b59a08858b6612989260877e17542addd877”. You have to remove (or rename) that container to be able to reuse that name.”

for a docker compose with two services. The problem is there is no container with the name befor I start it. I also defind the container_names in a specific way that docker compose doesn’t care about.
I think he makes a container with the first service and afterwards the wants to give the second one the same name. Is there any way to fix this? Am I missing something?

Is this container defined in a compose file or something that buildx would run when you want to build your images? How did you check the container names? docker ps -a would show you the stopped containers as well.

Yes the container is defined by an composerfile :

version: '3.8'
services:
  api:
    container_name: api_backend
    image: administrator/api:1
    build: ./api
    ports:
      - '3001:3001'

  client:
    container_name: client_frontend
    image: administrator/client:1
    build: ./client
    ports:
      - '3000:3000'
    stdin_open: true
    tty: true

Yes I checked with docker ps -a it shows a running container with the moby/buildkit:buildx-stable-1 name after running the docker-compose up command.

This compose file contains nothinglike the name in the error message

Did you do anyhting else than running docker compose up. Like creating a builder fo example in a CI pipeline or just a script which then runs docker compose up too?

Second question: do you have environment variables for buildx? Since you have too containers, if there is a variable that controls whether a new builder is created or not, it is possible the two build try to create the same.

No I didn’t crate a pipeline i’m pulling the repo manual and just typing docker-compse up.

I don’t think I have any environment variables, but I don’t know how to check

It’s either a .env file in your project folder or in variables in your shell which you can check by simply running

env

@hoeslefl Was this resolved? If yes what was the root cause and final resolution?

i, too, have this problem - any solutions?

Issue Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8793 → 0.0.0.0:0: listen tcp 0.0.0.0:8793: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

Solution
Step 1: netstat -ano | findstr :8793

Ressult
TCP 0.0.0.0:8793 0.0.0.0:0 LISTENING 16876
TCP [::]:8793 [::]:0 LISTENING 16876

step 2: taskkill /F /PID 16876

Step 3:
run docker image without --name
example : docker run -d -p8793:8793 image_id

it will work 99.9%

Your suggestion is not related to the original discussion. Would you like to share it in a new topic? I can move your post to a new topic. (by the way your commands could work on Windows only only)

FYI, Notes:

  • I had a properly functioning setup/system running Docker Engine version 25.0.3 and Docker Compose version 2.24.6
  • Using the same docker-compose.yml file the described problem occurred after upgrade to Docker Engine version 26.0.1 and Docker Compose version 2.26.1
  • the issue appears to be due to changes related to handling/parsing of file docker-compose.yml
    • the docker-compose.yml file makes use of both YAML aliases and BASH variables to define services.
    • docker compose version 2.24.6 handles/parses the file and yields the desired containers.
    • docker compose version 2.26.1 reports “container name “xxxx” is already in use” and doesn’t start any containers.

Additional/Update/Note:

  • For my case, if a container name is based upon a BASH variable, Docker Compose version 2.26.1 yields the message “container name “xxxx” is already in use”, whereas Docker Compose version 2.24.6 does not and starts the appropriately named container. For example:
services:

  db_node: &db_node
    container_name: db_node_${NODE}

Hope that helps. Please advise if I need upgrade to different/patched versions, thanks.

1 Like