Customizing the Docker Container Network

Source: Internet
Author: User
1. Create a bridge network similar to the previous default via bridge drive:
Docker Network create--driver Bridge my_net
If you do not specify a net defaults think 172.18.0.0/16:

2. Set up your own network segment simply specify the--subnet and--gateway parameters when creating the network segment:
Docker Network create--driver bridge--subnet 172.28.16.0/24--gateway 172.28.16.1 My_net2

3. You can view the two net cards created by Brctl show.

4. If you use a new network when creating a container, you need to specify it at startup by--network:
Docker run-it--network=my_net2 Daocloud.io/centos:6.6/bin/bash


You can also specify IP, specified by--ip:
Docker run-it--network=my_net2--ip 172.28.16.16 Daocloud.io/centos:6.6/bin/bash

5. Through Brctl show you can see that there are two machines on the My_net2:
6.

Note: Only networks created with--subnet can specify a static IP.

My_net created without specifying--subnet, if the specified static IP error is as follows:

Docker Host network topology

Customizing the Docker Container Network

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.