docker配置桥接网络
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker配置桥接网络相关的知识,希望对你有一定的参考价值。
配置桥接网络
复制网卡配置文件ifcfg-ens33为ifcfg-br0,修改ifcfg-br0
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-br0
[[email protected] network-scripts]# vim ifcfg-br0 //修改TYPE,NAME,DEVICE
修改网卡配置文件
//删除UUID,IPADDR,NETMASK,GATEWAY,DNS
//增加 BRIDGE=br0
[[email protected] network-scripts]# vim ifcfg-ens33
重启网卡服务
[[email protected] network-scripts]# systemctl restart network
查看
安装pipwork
[[email protected] ~]# yum install git -y
[[email protected] ~]# git clone https://github.com/jpetazzo/pipework
复制 /root/pipwork/pipwork到 /usr/local/bin/
[[email protected] ~]# cd pipework/
[[email protected] pipework]# cp pipework /usr/local/bin/
开启一个容器,给这个容器设置ip,gateway,进入容器看看是否能联网
[[email protected] ~]# docker run -itd --net=none centos bash
20e3285100628f86c21e0cfc887f2b874667001917568fcc34cb56cb4ce278ff
[[email protected] ~]# pipework br0 20e32851 192.168.221.100/[email protected]
[[email protected] ~]# docker exec -it 20e32851 /bin/bash
[[email protected] /]# ping www.baidu.com
PING www.a.shifen.com (119.75.213.61) 56(84) bytes of data.
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=1 ttl=128 time=23.2 ms
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=2 ttl=128 time=23.5 ms
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=3 ttl=128 time=23.2 ms
以上是关于docker配置桥接网络的主要内容,如果未能解决你的问题,请参考以下文章