Error message, Error response from daemon: service endpoint with name 'container name' already exists

Symptoms

The Docker containers fail to start with the error “Error response from daemon: service endpoint with name <container_name> already exists.”

Causes

The container is not started on the host, but on other nodes there is a cache status for it.

Diagnosing the problem

  1. On the host for the container, run the command to ensure that the container is not started:
    sudo docker ps -a | grep <container_name>

    The output shows that the container status is Exited.

  2. On the installer host, run the command:
    sudo docker network inspect ife | grep <container_name>

    The expected output is nothing, but if you get an output similar to: "Name":" "<container_name>" Then the output means that there is the issue on that host. In most case, the issue occurs on installer node, but if you can't find it on installer node, try the other nodes.

  3. Repeat step 2 for all other hosts except for the host for the container.

Resolving the problem

  1. On the host that you find the issue, run the command:
    sudo docker network disconnect -f ife <container_name>