2.5-docker Configuring Bridging Networks

Source: Internet
Author: User
Tags docker run

Docker Network Management – Configuring Bridging networks (CENTOS7)



To make it easier for machines and Docker containers in the local network to communicate, we often have the need to configure the Docker container to the same network segment as the host. This requirement is actually very easy to achieve, we just have to bridge the Docker container and the host's network card, and then the Docker container with IP on it.


* Install Pipwork #docker官方人员, a script written by Shell

git clone https://github.com/jpetazzo/pipework

CP ~/pipework/pipework/usr/local/bin/

No git command yum install git

* Open a container docker run-itd--net=none--name wyp123 Centos/bin/bash

Pipework br0 wyp123 172.7.15.201/[email protected] #201为容器的ip, the IP behind @ is the host IP, generating a network card.

Brctl addif br0 eth0 #eth0为宿主机网卡, this step is to connect the br0 and the Eth0 Bridge.

IP addr Add 172.7.15.107/24 br0 #把107的ip绑定在br0上

Docker exec-it Wyp123/bin/bash #进去后ifconfig查看就可以看到新添加的ip



Docker Network Management – Configuring Bridging networks (CENTOS6)



cd/etc/sysconfig/network-scripts/; CP Ifcfg-eth0 IFCFG-BR0

VI ifcfg-eth0//add Bridge=br0,bootproto=none, delete ipaddr,netmask,gateway,dns1

VI ifcfg-br0//Modify the device to Br0,type for Bridge, set the Eth0 network settings here

Service Network restart

Install Pipwork:

git clone https://github.com/jpetazzo/pipework;

CP ~/pipework/pipework/usr/local/bin/#为了方便执行命令 because the path is within $path


Open a container: Docker run-itd--net=none--name wyp123 Centos/bin/bash


Upgrade Package iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm, or you will get an error.

RPM-UVH https://repos.fedorapeople.org/openstack/EOL/openstack-grizzly/epel-6/ iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm #不安会报错Object "Netns" is unknown, try "IP Help"


Pipework Br0 wyp123 172.7.15.201/24 #配置IP

Docker exec-it Wyp123/bin/bash #进去后ifconfig查看就可以看到新添加的ip


2.5-docker Configuring Bridging Networks

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.