Pipework installing and assigning container fixed IP

Source: Internet
Author: User

os:centos7.0

The first step:

[Email protected] ~]# yum-y install git

Step Two:

[[email protected] ~]# git clone https://github.com/jpetazzo/pipework.git

Step Three:

[Email protected] ~]# CP-RP pipework/pipework/usr/local/bin/

Fourth Step: View Images

[email protected] ~]# Docker images

Configuring Docker containers in a local network environment

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 to the Docker container with IP on it.

Let's do the following, my host a address is 10.10.101.105/24, the gateway is 10.10.101.254, the address of the Docker container needs to be configured as 10.10.101.150/24. Do the following on host a:

#安装pipework
git clone https://github.com/jpetazzo/pipework
CP ~/pipework/pipework/usr/local/bin/
#启动Docker容器.
Docker RUN-ITD--name test1 Ubuntu/bin/bash
#配置容器网络, and connected to the bridge br0. The gateway is appended to the IP address with the @ designation.
#若主机环境中存在dhcp服务器, the IP can also be obtained by means of DHCP
#pipework br0 test1 DHCP
Pipework br0 test1 10.10.101.150/[email protected]
#将主机eth0桥接到br0上, and configure the eth0 IP on the br0. Because this is a remote operation, the intermediary network is broken, so it is executed in a single command.
IP addr Add 10.10.101.105/24 dev br0; \
IP addr del 10.10.101.105/24 dev eth0; \
Brctl addif br0 eth0; \
IP route del default; \
IP route add default GW 10.10.101.254 Dev br0

After completing the above steps, we found that the Docker container can already communicate with each other using the new IP and the machines in the host network.


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1789983

Pipework installing and assigning container fixed IP

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.