17

解决docker和kvm网络冲突的问题

 2 years ago
source link: https://blog.leixin.wang/611c78a3.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

解决docker和kvm网络冲突的问题

发表于 2020-04-18

| 分类于 linux

| 0

| 浏览 98次

字数统计: 301

|

阅读时长 ≈ 1

在一台kvm宿主机上安装了docker以后发现kvm的虚拟机无法获取到ip,配置静态ip网络也无法正常工作,但是宿主机的网络却很正,排查到libvirtd有如下报错

Apr 18 13:12:05 workspace libvirtd[721]: Failed to open file '/sys/class/net/vethaf21808/operstate': No such file or directory
Apr 18 13:12:05 workspace libvirtd[721]: unable to read: /sys/class/net/vethaf21808/operstate: No such file or directory
Apr 18 13:37:01 workspace libvirtd[721]: internal error: End of file from qemu monitor
Apr 18 13:37:25 workspace libvirtd[721]: internal error: End of file from qemu monitor

排查了一通没有更详细的消息,猜测是docker网桥导致的问题。于是查询到资料将docker网桥绑定到br0上面问题解决。操作如下

# vim /etc/docker/daemon.json
{
"bridge": "br0",
"default-gateway": "172.16.80.1" #此处ip地址为宿主机的真实网关
}

PS:
故障原因是docker server在启动的时候会创建docker网桥docker0,用于提供docker内部的网络通信以及容器和docker外界的通信。默认docker0会绑定物理网卡如enp0xxxeth0。而br0也绑定了物理网卡,docker0将物理网卡抢占,导致kvm使用br0无法正常获取网络。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK