参考链接

https://blog.csdn.net/Dawn__Z/article/details/84746055

 

**

注: 可以直接尝试用第二种方法,经试验,第二种方法可行。

**

一.查看当前状态

当前状态
ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:18:22:59:cd txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

安装bridge网络工具
yum -y install bridge-utils
安装后,查看网桥列表

brctl show

bridge name bridge id STP enabled interfaces
docker0 8000.0242182259cd no

停止、删除网桥docker0
停止:

ip link set dev docker0 down
删除:

brctl delbr docker0
删除成功后,查看:

brctl show

bridge name bridge id STP enabled interfaces

创建新的网桥
brctl addbr bridge0

设置网桥IP
ip addr add 192.168.0.1/24 dev bridge0
6. 启动网桥

ip link set dev bridge0 up
启动成功后,查看:

brctl show

bridge name bridge id STP enabled interfaces
bridge0 8000.000000000000 no
复制代码

ifconfig

bridge0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.255.0 broadcast 0.0.0.0
ether ca:ed:3e:52:f1:ee txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

二.注意

删除bridge0之后,我尝试不好用,然后我又按照删除bridge0的方式,同样把docker0删除.
然后再配置文件时候,增加如下代码:

停止docker服务

sudo systemctl stop docker.service
1
修改 /etc/docker/daemon.json, 指定ip地址

vim /etc/docker/daemon.json
1
输入:

{
 "bip": "172.18.0.1/24",
}
1
2
3
然后重启docker服务即可。

service docker restart

 

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐