Docker USES custom Bridges
- 2020-05-17 06:58:23
- OfStack
By default, the Docker service creates an docker0 bridge that connects other physical or virtual network CARDS at the kernel layer, placing all containers and localhosts on the same physical network.
Users can also specify a bridge to connect to each container, as follows:
1. Install the bridge-utils toolkit first
$ sudo apt-get install bridge-utils
You can then use "brctl show" to view the current bridge information and 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
You can see it with "brctl show" when you add it
$ brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000000000000 no
docker0 8000.56847afe9799 no
3. Edit/etc default/docker. io file, add the following Docker parameters, is Docker default to the newly added above the bridge
DOCKER_OPTS="-b=br0"
4. Restart the docker service
sudo service docker.io restart
5. Create a new container and see that it is already connected to br0.
6. Finally, if you want to delete the bridge, you can
$ sudo ip link set dev br0 down
$ sudo brctl addbr br0