Custom Network Bridge
In addition to the default bridge docker0
, users can specify a bridge to connect to each container.
Use -b BRIDGE
or to specify the bridge to use when starting the Docker service --bridge=BRIDGE
.
If the service is already running, you need to stop the service and delete the old bridge.
$ sudo service docker stop$ sudo ip link set dev docker0 down$ sudo brctl delbr docker0
BRIDGE0
$ sudo brctl addbr bridge0$ sudo ip addr add 192.168.5.1/24 dev bridge0$ sudo ip link set dev bridge0 up
Review the confirmation bridge creation and launch.
$ IP Addr Show bridge04:bridge0: <BROADCAST,MULTICAST> MTU Qdisc noop State up group default Link/ether 66: 38:d0:0d:76:18 BRD ff:ff:ff:ff:ff:ff inet 192.168.5.1/24 scope global bridge0 Valid_lft forever preferred_lft for Ever
Configure the Docker service, which is the default bridge to the created bridge.
$ Echo ' docker_opts= '-b=bridge0 ' >>/etc/default/docker$ sudo service DOCKER start
Start the Docker service. Create a new container, and you can see that it has been bridged bridge0
.
You can continue to brctl show
view bridged information with commands. In addition, you can use the ip addr
and commands in the container ip route
to view IP address configuration and routing information.
This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1789556
To start the Docker service, in addition to the default Docker0 bridge, how to specify the network bridge to use