the process of establishing Docker bridging physical network on CENTOS7 host
Host network card information:
name:ens0
ip:192.168.184.99
gateway:192.168.184.2
dns:192.168.184.2
1. Stop Docker Service
~#:service Docker Stop
2. Remove DOCKER0 network card
~#:ip Link Set dev Docker0 down
~#:brctl delbr Docker0
3. New Bridge physical network virtual NIC Br0
~#:brctl addbr br0
~#:ip link set dev br0 up
~#:ip addr add 192.168.184.100/24 dev br0 #为br0分配物理网络中的ip地址
~#:ip Addr del 192.168.184.99/24 dev ens0 #将宿主机网卡的IP清空
~#:brctl addif br0 ens0 #将宿主机网卡挂到br0上
~#:ip route del default #删 In addition to the original route
~#:ip route add default via 192.168.184.2 Dev br0 #为br0设置路由
4. Set Docker service startup parameters
Note here that different Linux operating systems Docker have different configuration files
CentOS in/etc/sysconfig/docker
Other operating systems please go to the URL below
https://docs.docker.com/installation/#installation
~#:vim/etc/sysconfig/docker #在OPTIONS = '--selinux-enabled ' This line is modified to options= '--selinux-enabled-b= Br0 ' that allows the Docker service to be bridged using the Br0 NIC when it is started
5. Start Docker Service
~#:service Docker Start
6. Install pipework
~#:git clone https://github.com/jpetazzo/pipework
~#:CP ~/pipework/pipework/usr/local/bin/
7. Start a container that sets up the network manually
It is best not to let Docker automatically get IP, the next time the launch will be changed and automatically obtained IP May and physical network segment IP conflict
~#:d ocker run-itd--net=none--name=test Centos7/bin/bash
9. Set up a ip@ gateway with the address segment of the bridging physical network for the test Container
~#:p ipework br0 test 192.168.184.11/24@192.168.184.2
10. Access to Container view IP
~#:d ocker Attach Test
Turn from: http://blog.163.com/hk_bs/blog/static/245038011201631931849968/