守护进程响应错误:端点名称 container_name 已存在于网络 bridge 中
Error response from daemon: endpoint with name container_name already exists in network bridge
ID: docker/container-name-orphaned-network-endpoint
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 20.10.17 | active | — | — | — |
| Docker 24.0.6 | active | — | — | — |
| Docker 25.0.0 | active | — | — | — |
根因分析
容器从网络中断开时未正确移除端点,导致网络内部状态中残留了过期的端点条目。
English
A container was disconnected from a network without properly removing the endpoint, leaving a stale endpoint entry in the network's internal state.
官方文档
https://docs.docker.com/engine/reference/commandline/network_disconnect/解决方案
-
使用 'docker network disconnect -f bridge container_name' 显式断开容器与网络的连接,以移除过期的端点。
-
如果容器已不存在,使用 'docker network prune' 清理所有未使用的网络及其孤立的端点。
-
使用 'docker network inspect bridge' 检查网络端点列表,然后通过 'docker network disconnect -f bridge <container_id>' 手动断开每个过期的容器。
无效尝试
常见但无效的做法:
-
70% 失败
Restarting Docker does not clean up stale endpoints in individual networks; it only resets the daemon state but persistent network data remains.
-
90% 失败
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'.
-
60% 失败
The container may already be removed, but the stale endpoint persists; force removal does not clean up orphaned endpoints in the network.