docker0网卡的默认IP地址为172.17.0.1/16
因此很可能会与企业网中的业务地址冲突,为了解决这个问题,必须修改docker0的网卡配置,操作如下
1、查看网卡docker0的默认地址 ip address show docker0
ip address show docker0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:64:11:2f:d4 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
2、关闭docker服务 systemctl stop docker
3、使用cat
查看docker的配置文件 cat /etc/docker/daemon.json
cat /etc/docker/daemon.json
{
"data-root": "/var/lib/docker",
"live-restore": true,
"log-driver": "json-file",
"log-opts": {
"max-file": "3",
"max-size": "10m"
}
}
3、使用vim
修改docker的配置文件,默认配置文件中不存在"bip": "172.19.252.1/24",
将此配置插入到配置文件中。默认不写就是172.17.0.1/16
vim /etc/docker/daemon.json
{
"data-root": "/var/lib/docker",
"live-restore": true,
"log-driver": "json-file",
"bip": "172.19.252.1/24",
"log-opts": {
"max-file": "3",
"max-size": "10m"
}
}
4、启用docker服务systemctl start docker
5、刷新并查看docker网卡配置,此时我们看到ip地址已正确更改为172.19.252.1/24的配置
ip addr flush dev docker0
ip addr show docker0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:64:11:2f:d4 brd ff:ff:ff:ff:ff:ff
inet 172.19.252.1/24 brd 172.19.252.255 scope global docker0
valid_lft forever preferred_lft forever
6、如果ip还未修改过来,请尝试reboot
重启服务器后再次查看