docker network_error ai_generated true

Error response from daemon: endpoint with name container_name already exists in network bridge

ID: docker/container-name-orphaned-network-endpoint

Also available as: JSON · Markdown · 中文
82%Fix Rate
85%Confidence
1Evidence
2024-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Docker 20.10.17 active
Docker 24.0.6 active
Docker 25.0.0 active

Root Cause

A container was disconnected from a network without properly removing the endpoint, leaving a stale endpoint entry in the network's internal state.

generic

中文

容器从网络中断开时未正确移除端点,导致网络内部状态中残留了过期的端点条目。

Official Documentation

https://docs.docker.com/engine/reference/commandline/network_disconnect/

Workarounds

  1. 85% success Disconnect the container from the network explicitly using 'docker network disconnect -f bridge container_name' to remove the stale endpoint.
    Disconnect the container from the network explicitly using 'docker network disconnect -f bridge container_name' to remove the stale endpoint.
  2. 90% success If the container no longer exists, prune stale network endpoints with 'docker network prune' which removes all unused networks and their orphaned endpoints.
    If the container no longer exists, prune stale network endpoints with 'docker network prune' which removes all unused networks and their orphaned endpoints.
  3. 95% success As a last resort, inspect the network with 'docker network inspect bridge' to list endpoints, then manually disconnect each stale container by its ID using 'docker network disconnect -f bridge <container_id>'.
    As a last resort, inspect the network with 'docker network inspect bridge' to list endpoints, then manually disconnect each stale container by its ID using 'docker network disconnect -f bridge <container_id>'.

中文步骤

  1. 使用 'docker network disconnect -f bridge container_name' 显式断开容器与网络的连接,以移除过期的端点。
  2. 如果容器已不存在,使用 'docker network prune' 清理所有未使用的网络及其孤立的端点。
  3. 使用 'docker network inspect bridge' 检查网络端点列表,然后通过 'docker network disconnect -f bridge <container_id>' 手动断开每个过期的容器。

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Restarting Docker does not clean up stale endpoints in individual networks; it only resets the daemon state but persistent network data remains.

  2. 90% fail

    The 'bridge' network is a default network that cannot be removed; this command will fail with 'Error response from daemon: network bridge is a pre-defined network'.

  3. 60% fail

    The container may already be removed, but the stale endpoint persists; force removal does not clean up orphaned endpoints in the network.