docker网卡与物理网卡冲突

2022-12-08

方法一:修改docker网络

写入docker配置文件

cat > /etc/docker/daemon.json < EOF
{
	"bip" : "172.19.0.1/16"
}
EOF

停止并关闭docker0

ip link del dev docker0 down

重启配置文件

systemctl daemon-reload
systemctl restart docker

创建docker0 网卡

ip link add docker0 type bridge

添加网桥

ip addr add 172.19.0.1/16 dev docker0

启动网卡

ip link set dev docker0 up

方法二:docker更改默认网卡(临时)

创建docker0网卡

cat > /etc/sysconfig/network-scripts/ifcfg-docker0 < EOF
DEVICE="docker0"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="static"
IPADDR="172.18.0.1"
NETMASK="255.255.255.0"
GATEWAY="172.18.0.1"
DEFROUTE="yes"
NM_CONTROLLED="no"
EOF

重启网卡

ifdown docker0 && ifup docker0