cli: "endpoint with name XX already exists in network" can't disconnect container from bridge

Description

Firstly, mycontainer can’t be stopped by docker stop mycontainer After docker rm -f mycontainer, the same container can’t run with docker: Error response from daemon: endpoint with name mycontainer already exists in network bridge. Tried docker network disconnect bridge mycontainer but the error still exists, docker network inspect bridge will see mycontainer there

Steps to reproduce the issue: 1.docker rm -f somecontainer 2.try run the same one again 3. can’t start it

Describe the results you received: docker: Error response from daemon: endpoint with name mycontainer already exists in network bridge.

Describe the results you expected: start normally

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:           18.09.5
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        e8ff056
 Built:             Thu Apr 11 04:43:34 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.5
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       e8ff056
  Built:            Thu Apr 11 04:13:40 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 2
 Running: 1
 Paused: 0
 Stopped: 1
Images: 12
Server Version: 18.09.5
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-957.10.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.692GiB
Name: 35.localdomain
ID: LZQO:XNBR:HQBY:AUOJ:G4VG:4SYY:FQBB:SI2W:SPU2:4D56:GHAN:HHHU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

Additional environment details (AWS, VirtualBox, physical, etc.): VirtualBox

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 8
  • Comments: 24 (4 by maintainers)

Commits related to this issue

Most upvoted comments

After service docker restart, things back to normal.

This helped for me (I used the docker-compose): First of all remove the invalid container docker container rm <container> or docker-compose rm <service> (if you are using the docker-compose)

Ensure that the container is gone: docker container ls | grep <container> or docker-compose ps | grep <container> there must be no such container in output

Now it may still be connected to the network, so disconnect it: docker network disconnect -f <network> <container> You must to use -f flag to enforce disconnecting the nonexistent container

Ensure that is ok: docker network inspect | grep <container> there must be no such container in output

And then you may to create and run the new container, for my docker-compose case I run docker-compose up -d <service> - this command creates container and automatically adds it the network

Hello! I have same issue, after stopping container his network is still in network configuration, that produces the running error:

endpoint with name agitated_nobel already exists in network bridge

See docker inspect:

$ docker network inspect bridge
....
"ead2e4080f561c2212c00fb1340c2f4532c1bdec5e638671c7a09cad7c40f414": {
                "Name": "agitated_nobel",
                "EndpointID": "f36c06d17e206cbf932a52be0b80f06fd8621b57e98fa77caec83cbeb9584804",
                "MacAddress": "02:42:ac:11:00:0f",
                "IPv4Address": "172.17.0.15/16",
                "IPv6Address": ""
            }
....

And try to find a container:

$ docker ps -a | grep agitated_nobel

Nothing…

Removing network with -f flag:

$ docker network disconnect -f bridge agitated_nobel

agitated_nobel from network bridge disappeared.

My docker info:

$ docker info
Containers: 61
 Running: 31
 Paused: 0
 Stopped: 30
Images: 65
Server Version: 17.05.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
 apparmor
Kernel Version: 4.9.164-0409164-generic
Operating System: Ubuntu 14.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 30.42GiB
Name: jenkins-agents-1
ID: QE4A:FTD5:X7KN:CV6G:5OEE:U26I:EDBH:X24J:GOW7:YN6J:CRIH:XL3E
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 229
 Goroutines: 462
 System Time: 2020-02-04T06:53:02.844260111Z
 EventsListeners: 22
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 registry:5000
 registry2:5000
 127.0.0.0/8
Live Restore Enabled: false

After service docker restart, things back to normal.

highly under-rated comment.

Guys, I’ve run through the same issue and the steps bellow worked for me.

1 - docker rm -f container_name

2 - docker network disconnect -f network_name container_name

( in my case the name of the network was Bridge, but you can find out all networks with this command docker network ls)

3 - (check if it was removed) - docker network inspect network_name | grep container_name

4 - (if it was removed) - just run the container again.

I Hope this information is usefull for more people.

Run in same issue, any update?

$ docker ps -a | grep  xxxxxxxxx-certserver
$ docker-compose up -d
Creating xxxxxxxxx-certserver ... error

ERROR: for xxxxxxxxx-certserver  Cannot start service xxxxxxxxx-certserver: endpoint with name xxxxxxxxx-certserver already exists in network host

ERROR: for xxxxxxxxx-certserver  Cannot start service xxxxxxxxx-certserver: endpoint with name xxxxxxxxx-certserver already exists in network host
ERROR: Encountered errors while bringing up the project.
$ docker ps -a | grep  xxxxxxxxx-certserver
0f8709c76733        xxxxxxxxxx:5000/wxx/xxxxxxxxx-certserver:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx         "/bin/sh /data/webof…"   3 seconds ago       Created                                              xxxxxxxxx-certserver
$ docker-compose down
Removing xxxxxxxxx-certserver ... done
$ docker network disconnect --force host xxxxxxxxx-certserver
$ docker-compose up -d
Creating xxxxxxxxx-certserver ... done
$ docker ps -a | grep  xxxxxxxxx-certserver
85443ce71285        xxxxxxxxxx:5000/wxx/xxxxxxxxx-certserver:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx         "/bin/sh /data/webof…"   4 seconds ago       Up 3 seconds                                         xxxxxxxxx-certserver

Now it may still be connected to the network, so disconnect it: docker network disconnect -f <network> <container> You must to use -f flag to enforce disconnecting the nonexistent container

This is a very helpful addition! Thanks!

Ran into this after recreating a container after it was locked up and wasn’t responding to stops or SIGKILL ERROR: for mongo Cannot start service mongo: endpoint with name integration-test-mongo already exists in network

Command history:

docker ps
docker stop e6cbee8efb39 6b05798cf949 a198a43ee674 e5d6084b4625 //stopping a bunch of stuff
docker ps
docker stop a198a43ee674 //huh, it didn't stop, this was the problem mongo container
docker ps
docker stop -f a198a43ee674 //thought f was an option to force
docker stop --help //figured out it wasn't
docker stop -t 1 a198a43ee674
docker ps
docker kill a198a43ee674 //trying to kill it
docker ps
docker kill a198a43ee674 //it was still there
docker kill --signal=SIGKILL a198a43ee674
docker ps //still there after SIGKILL
docker rm a198a43ee674
docker rm -f a198a43ee674 //finally was able to force remove

docker info

 Server Version: 19.03.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.9.184-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64

The container happened to be mongo, but I don’t think it matters.

mongo:
  image: mongo:4.1.4
  container_name: integration-test-mongo
  hostname: mongo
  ports:
    - '27017:27017'

Restarting the service (obviously) resets the network, and then allows me to relaunch the container.

Might be something with the forced rm of a running container that doesn’t clean up it’s network connection?