May 22, 2021 Docker From entry to practice
This chapter describes some of Docker's advanced network configurations and options.
When Docker starts, a docker0 virtual bridge is
docker0
on the host, which is actually a bridge for Linux and can be understood as a software switch.
It forwards between the gateways mounted to it.
At the same time, Docker randomly assigns an address to the docker0 interface for a locally
docker0
RFC1918).
F
or
172.17.42.1
with
255.255.0.0
The gateway in the container that starts thereafter is also automatically assigned the address of the same network segment
172.17.0.0/16
When a Docker container is created, a pair of
veth pair
are created (when packets are sent to one interface, the other interface can receive the same packets). O
ne end of the interface is inside the container,
eth0
and the other end is
docker0
bridge, with
veth
vethAQI2QT
I
n this way, hosts can communicate with containers, and containers can communicate with each other.
Docker creates a virtual shared network between the host and all containers.
The next section will cover all of Docker's network custom configurations in some scenarios. and to adjust, supplement, or even replace Docker's default network configuration with linux commands.