docker networking ai_generated true

endpoint with name already exists in network

ID: docker/docker-network-endpoint-exists

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
27 active

Root Cause

A container with the same name is already connected to the target network. This often happens after a container crash or forced removal that left a stale network endpoint.

generic

Workarounds

  1. 92% success Disconnect the stale endpoint from the network first
    docker network disconnect -f <network> <container-name> && docker network connect <network> <container-name>

    Sources: https://docs.docker.com/reference/cli/docker/network/disconnect/

  2. 88% success Remove the dead container and restart with docker compose up
    docker rm -f <container-name> && docker compose up -d — Compose will recreate the container with a fresh network endpoint

    Sources: https://docs.docker.com/compose/

Dead Ends

Common approaches that don't work:

  1. Deleting and recreating the entire Docker network 70% fail

    All other containers on that network lose connectivity and must be reconnected

  2. Renaming the container to avoid the conflict 75% fail

    The stale endpoint still occupies the network slot; the old endpoint must be cleaned up

Error Chain

Leads to:
Preceded by:
Frequently confused with: