User custom network driver has three: Bridge, Overlay and Macvlan. Overlay and Macvlan are used to create cross -host networks.
Specify the Bridge driver to create a network:
can see a new bridge BR-87200B9D7FF4. The 87200B9D7FF4 here is exactly the short ID of the new Bridge network My_net. Execute the docker network inspect to see the following My_net configuration information:
Here Subnet is the IP network section of Docker automatically allocated.
We can also specify the IP network segment by —Subset and – Gateway:
The container uses a new network to be specified by –Network when it starts.
So far, the container’s IP is all allocated from the Subnet. We can specify a static IP by –IP itself.
Note: Only use the network created by – Subnet to specify the static IP. When the My_net is created, it is not specified -SUBNET, so it cannot be used -IP
The container under the same net bridge can be ping to each other
The container under different network bridges If you want to connect, you can add a network bridge to one container.
Through Docker Network Connect:
At this time, you can ping through
1 1 1 1 1 1 1 10benben
2023-01-10
ES