A network mode
- default --net = bridge
2 .-- = NET Host
busybox docker run -it default operating network generates a separate command space
docker run -it --net = host busybox --net = host network used in conjunction with the host command space, other isolated
using port corresponding to the port occupied by the host in the container;
. 3 .-- nET = none
Docker Expediting IT RUN = none - net network independent, but each configured with any address
4 .-- net = container: namedocker exec -it bs sh run generic container
netstat -nltp
docker run -itd --name nginx05 --net=container:bs nginxnetstat -nltp
The Send-Recv-Q proto the Local the Address Foreign the Address State Q the PID / Program name
TCP 0.0.0.0:80 0.0.0.0:* the LISTEN 0 0 -
has the same network information, except for the container, the other is isolated;
5. Custom Network
as with the default bridge principle, but the custom network includes an internal DNS discovery, can communicate over the network between a name or host name of the container vesseldocker network create bs-test to create a network bs-test
- Net --name Expediting IT RUN BS4 Docker BS-Test busybox
Docker RUN Expediting IT --name BS3 - Net Test BS-busybox
then ping each other may communicate; may also communicate with the host name; link communication
II. Principles container network access
between the host and the Docker communication with the container and the iptables snat dnat
data from the container to the host data to the host card configuration Iptable snat docker0 through the bridge.
NIC data from the host to the container to the container is arranged iptables Dnat docker0 card through the bridge.