Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error response from daemon: service endpoint with name

Tags:

docker

I'm getting this strange error, when I try to run a docker with a name it gives me this error.

docker: Error response from daemon: service endpoint with name qc.T8 already exists.

However, there is no container with this name.

> docker ps -a
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

> sudo docker info

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 3
Server Version: 1.12.3
Storage Driver: aufs
 Root Dir: /ahdee/docker/aufs
 Backing Filesystem: extfs
 Dirs: 28
 Dirperm1 Supported: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null bridge host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor
Kernel Version: 3.13.0-101-generic
Operating System: Ubuntu 14.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 64
Total Memory: 480.3 GiB

Is there anyway I can flush this out?

like image 225
Ahdee Avatar asked May 02 '17 16:05

Ahdee


People also ask

How do I remove a container from my network?

Stop and remove all containers The command docker container ls -aq generates a list of all containers. Once all containers are stopped, remove them using the docker container rm command, followed by the containers ID list.

What docker is my image running?

You can check with this command systemctl status docker it will show the status of the docker. If you want to start you can use systemctl start docker instead of systemctl you can try also with service , service docker status and service docker start respectively.

How do I list a docker container?

In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command. This command provides a variety of ways to list and filter all containers on a particular Docker engine.


6 Answers

Just in case someone else needs this. As @Jmons pointed out it was a weird networking issue. So I solved this by forcing a removal

docker network disconnect --force bridge qc.T8

A

like image 189
Ahdee Avatar answered Oct 04 '22 06:10

Ahdee


TLDR: restart your docker daemon or restart your docker-machine (if you're using that e.g. on a mac).

Edit: As there are more recent posts below, they answer the question better then mine. The Network adapter is stuck on the daemon. I'm updating mine as its possibly 'on top' of the list and people might not scroll down.

  1. Restarting your docker daemon / docker service / docker-machine is the easiest answer.

  2. the better answer (via Shalabh Negi):

docker network inspect <network name>
docker network disconnect <network name> <container id/ container name>

This is also faster in real time if you can find the network as restarting the docker machine/demon/service in my experience is a slow thing. If you use that, please scroll down and click +1 on their answer.


So the problem is probably your network adapter (virtual, docker thing, not real): have a quick peek at this: https://github.com/moby/moby/issues/23302.

To prevent it happening again is a bit tricky. It seems there may be an issue with docker where a container exits with a bad status code (e.g. non-zero) that holds the network open. You can't then start a new container with that endpoint.

like image 35
Jmons Avatar answered Oct 01 '22 06:10

Jmons


docker network inspect <network name>
docker network disconnect <network name> <container id/ container name>

You can also try doing:

docker network prune
docker volume prune
docker system prune 

these commands will help clearing zombie containers, volume and network. When no command works then do

sudo service docker restart

your problem will be solved

like image 24
Shalabh Negi Avatar answered Sep 30 '22 06:09

Shalabh Negi


docker network rm <network name>

Worked for me

like image 39
vladimir vojtisek Avatar answered Sep 30 '22 06:09

vladimir vojtisek


Restarting docker solved it for me.

like image 43
Gaurav Avatar answered Sep 30 '22 06:09

Gaurav


I created a script a while back, I think this should help people working with swarm. Using docker-machine this can help a bit.

https://gist.github.com/lcamilo15/7aaaebe71852444ea8f1da5c4c9c84b7

declare -a NODE_NAMES=("node_01", "node_02");
declare -a CONTAINER_NAMES=("container_a", "container_b");
declare -a NETWORK_NAMES=("network_1", "network_2");
for x in "${NODE_NAMES[@]}"; do;
    docker-machine env $x;
    eval $(docker-machine env $x)
    for CONTAINER_NAME in "${CONTAINER_NAMES[@]}"; do;
        for NETWORK_NAME in "${NETWORK_NAMES[@]}"; do;
            echo "Disconnecting $CONTAINER_NAME from $NETWORK_NAME"
            docker network disconnect -f $NETWORK_NAME $CONTAINER_NAME;
        done;
    done;
done;
like image 37
lac_dev Avatar answered Sep 30 '22 06:09

lac_dev