docker network bridge, host, none

docker There are three default network bridge, host, none

bridge bridge network

After docker installation is successful, will create a bridge docker0 in the host, bridge docker0 can be understood as a virtual switch

Run a nginx container

docker run --name web -d nginx

Install bridge-utils

yum install bridge-utils

 

FIG fancy, docker0 bridge connects two ports vethe1db678, if10.

It considered vethe1db678, if10 a network card, which can communicate between the card and the card is inserted in one end docker0 switch, and the other end connected nginx container, and the container can host communication.

Check containers ip docker inspect web 

Access to the container

curl 172.17.0.2

 

Create a busybox  

docker run -d --name=busybox busybox /bin/sh -c "while true; do sleep 3600;done"

docker exec -it busybox /bin/sh

In another busybox may ping the container nginx

ping 172.17.0.2

 

Communication process between containers:

After busybox created, and then creates a network card will vethe447c46, if14, inserted in one end of the switch docker0, busybox end connected containers.

After sending the request to busybox docker0, docker0 to the request in nginx.

 

Host network represents a network using a physical container machine namespace. Port, the container can not be used by the physical machine being used; the port, the container being used by the physical machine can not be used

none i.e. no communication between the network can not, with the host vessel, the vessel and the container. Some do not need to run network tasks, such as batch data.

Published 51 original articles · won praise 14 · views 40000 +

Guess you like

Origin blog.csdn.net/u010606397/article/details/90401513