Configuring Docker container fixed IP using pipework

Source: Internet
Author: User
Tags docker run

First, let's talk about Docker's network mode:

When we use Docker run to create a container, we can use the--net option to specify the network mode of the container, with Docker having a total of 4 network modes:

1:bridge mode,--net=bridge (default).

This is the default setting for the Dokcer network. After installing Docker, the system automatically adds a bridge Docker0 for Docker to use, and when we create a new container, the container obtains an IP address of the same network segment as the DOCKER0 through DHCP. and is connected to the Docker0 bridge by default to realize the network interoperability between the container and host. As follows:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/28/wKioL1cVo2Ow6j7qAAA32YRYSMI530.png "title=" 1.PNG " alt= "Wkiol1cvo2ow6j7qaaa32yrysmi530.png"/>

2:host mode,--net=host.

The container created in this mode will not have its own independent network Namespace, that is, there is no independent networking environment. It uses the host's IP and port.


3:container mode,--net=container:name_or_id.

This pattern is to specify an existing container to share the IP and port of the container. In addition to the network of two containers shared, other such as file system, process, etc. or isolated.


4:none mode,--net=none.

In this mode, Dokcer does not make any network configuration for the container. We need to add the network card for the container, configure the IP.

Therefore, if you want to use pipework to configure the IP address of the Docker container, you must be in the None mode.


Pipework Installation:

# wget https://github.com/jpetazzo/pipework/archive/master.zip# Unzip pipework-master.zip# CP pipework-master/ pipework/usr/local/bin/# chmod +x/usr/local/bin/pipework


Create a container for the none mode, assigning IP to it.

#docker run-idt--name test--net=none resin#pipework DOCKER0 test 172.17.0.100/[email protected]

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/2A/wKiom1cVowqzo33bAABqs1fHI6s792.png "title=" 2.PNG " alt= "Wkiom1cvowqzo33baabqs1fhi6s792.png"/>

The above operation assigns a 172.17.0.100 IP address to the new test container.


This article from the "Play God Clown" blog, reproduced please contact the author!

Configuring Docker container fixed IP using pipework

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.