我正在尝试更新正在运行的 docker 容器的网络。
注意:运行容器时我没有连接任何网络。
[root@stagingrbt ~]# docker network connect host cdf8d6e3013d
Error response from daemon: container sharing network namespace with another container or host cannot be connected to any other network
[root@stagingrbt ~]# docker network connect docker_gwbridge cdf8d6e3013d
error during connect: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/networks/docker_gwbridge/connect: EOF
[root@stagingrbt ~]# docker network create -d host my-host-network
Error response from daemon: only one instance of "host" network is allowed
[root@stagingrbt ~]# docker network ls
NETWORK ID NAME DRIVER SCOPE
495080cf93e3 bridge bridge local
cf0408d6f13f docker_gwbridge bridge local
2c5461835eaf host host local
87e9cohcbogh ingress overlay swarm
84dbd78101e3 none null local
774882ac9b09 sudhirnetwork bridge local
原文由 sudhir tataraju 发布,翻译遵循 CC BY-SA 4.0 许可协议
当你启动一个容器时,例如:
它默认连接到
bridge
网络,检查它:如果您尝试将其连接到
host
网络:你得到一个错误:
您必须删除容器并在主机网络上再次运行它:
此限制在桥接网络上不存在。你可以启动一个容器:
断开它与桥接网络的连接,然后将其重新连接到另一个桥接网络。
另请注意,根据 文档: