The Docker service will create a docker0 bridge by default, which connects other physical or virtual network cards at the kernel layer, which places all containers and local hosts on the same physical network.
Users can also specify a bridge to connect each container, the steps are as follows:
1. First install the bridge-utils toolkit
$ sudo apt-get install bridge-utils
Then you can use "brctl show" to view the current bridge information, and you can see that there is currently only one docker0
$ brctl show bridge name bridge id STP enabled interfaces docker0 8000.56847afe9799 no
2. Then create a bridge br0
$ sudo brctl addbr br0 $ sudo ip addr add 192.168.66.1/24 dev br0 $ sudo ip link set dev br0 up
After adding, you can use "brctl show" to view it
$ brctl show bridge name bridge id STP enabled interfaces br0 8000.000000000000 no docker0 8000.56847afe9799 no
3. Edit the /etc/default/ file and add the following Docker parameters, which isDocker uses the newly added bridge above by default
DOCKER_OPTS="-b=br0"
4. Restart the docker service
sudo service restart
5. Create a new container and you can see that it has been bridged to br0.
6. Finally, if you want to delete the bridge, you can
$ sudo ip link set dev br0 down
$ sudo brctl addbr br0
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.