Establishing Docker Bridge network under CENTOS7

Source: Internet
Author: User
Tags get ip git clone
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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.