基于Centos7.x构建Docker桥接网络,
配置bridge桥接网络可以直接设置网卡配置文件:
自定义桥接网络设置如下:
关掉docker0ifconfig docker0 down删除dockerbrctl delbr docker0增加网桥br0yum install bridge-utilsbrctl show #查看物理机上有哪些网桥brctl addbr docker_new0 #自定义网桥
/etc/sysconfig/network-scripts/下,修改ifcfg-ens33网卡配置,同时增加ifcfg-br0桥接网卡配置,
vi ifcfg-ens33内容修改为如下:
DEVICE=ens33BOOTPROTO=noneNM_CONTROLLED=noONBOOT=yesTYPE=EthernetBRIDGE="br0"IPADDR=192.168.0.110NETMASK=255.255.255.0GATEWAY=192.168.0.1USERCTL=no
vi ifcfg-br0内容如下:
DEVICE="br0"BOOTPROTO=noneIPV6INIT=noNM_CONTROLLED=noONBOOT=yesTYPE="bridge"IPADDR="192.168.0.110"NETMASK="255.255.255.0"USERCTL=no
启动docker服务,即可
service docker start
安装pipeworkyum install -y gitgit clone https://github.com/jpetazzo/pipeworkcp ~/pipework/pipework /usr/local/bin/启动容器并设置网络docker run -itd --net=none --name=ale centos68 /bin/bashpipework br0 ale 192.168.0.111/24@192.168.0.110进入容器查看ipdocker exec ale ifconfig