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