yum -y install bridge-utils [root@linux-node2 ~]# systemctl stop docker [root@linux-node2 ~]# ifconfig docker0 down [root@linux-node2 ~]# brctl delbr docker0 [root@linux-node2 network-scripts]# cat ifcfg-br0 DEVICE=br0 ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static TYPE=Bridge IPADDR=192.168.56.12 NETMASK=255.255.255.0 GATEWAY=192.168.56.2 [root@linux-node2 network-scripts]# cat ifcfg-eth0 TYPE=Ethernet BOOTPROTO=none IPV6INIT=no NAME=eth0 DEVICE=eth0 ONBOOT=yes BRIDGE=br0 [root@linux-node2 network-scripts]# systemctl restart network [root@linux-node2 network-scripts]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000 link/ether 00:0c:29:ac:7e:6d brd ff:ff:ff:ff:ff:ff inet6 fe80::20c:29ff:feac:7e6d/64 scope link valid_lft forever preferred_lft forever 6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether 00:0c:29:ac:7e:6d brd ff:ff:ff:ff:ff:ff inet 192.168.56.12/24 brd 192.168.56.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feac:7e6d/64 scope link valid_lft forever preferred_lft forever [root@linux-node2 network-scripts]# vi /etc/sysconfig/docker OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false -b=br0' systemctl restart network pipework的安装 wget https://github.com/jpetazzo/pipework/archive/master.zip unzip master.zip cp pipework-master/pipework /usr/local/bin/ chmod +x /usr/local/bin/pipework 这里最好不要让docker自动获取ip,下次启动会有变化而且自动获取的ip可能会和物理网段中的ip冲突 docker run -itd --net=none --name=test centos7 /bin/bash 为test容器设置一个与桥接物理网络同地址段的ip@网关 pipework br0 test 192.168.56.11/24@192.168.56.2
docker 网络设置桥接网卡
原创
©著作权归作者所有:来自51CTO博客作者小小三郎1的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:rabbitmq部署笔记
下一篇:Docker的CPU限制限制
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
centos 双网卡配置
双网卡
双网卡