为什么 docker 切换网络模式为 bridge 会启动失败?

2022 年 4 月 29 日
 1024hex

一开始是以 host 创建的容器,后来想切换成 bridge

命令:

docker network connect bridge ubuntu20
docker container start ubuntu

报错: Error response from daemon: failed to add interface veth4569079 to sandbox: error setting interface "veth4569079" IP to 172.17.0.3/16: cannot program address 172.17.0.3/16 in sandbox interface because it conflicts with existing route {Ifindex: 16 Dst: 172.17.0.0/16 Src: 172.17.0.1 Gw: <nil> Flags: [] Table: 254} Error: failed to start containers: ubuntu20

但是换回 host 之后又能正常启动

--network bridge新创建的容器,inspect 查看配置由网关,而 host->bridge 的容器却没看到有网关的信息

1671 次点击
所在节点    问与答
2 条回复
Nnq
2022 年 4 月 30 日
不是写了🈶️冲突么
julyclyde
2022 年 5 月 5 日
bridge 的话你需要换一个 IP 地址了,和主网卡同网段的“隔壁”的 IP 地址

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/850076

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX