Docker 101 : Host network and Bridge network
But as we run more and more containers using the host network driver, it will become harder to know which ports are used and which are not.
Usually the host network driver is used when we want to run a single or a very limited number of containers.
To reach the container the IP address and the ports of the host are used, so the docker network "infrastructure" is not used.
We could run an "nginx" container using the host network driver as follows:
The bridged connections uses the default docker bridge for the connections between the containers and also between the containers and the "outside".
The above example uses the default bridge, if we have a user-defined network, we will need to mention it using the "--network" flag when running the container.
All the packets arriving on port "8080" on the host interface will be passed on to the "nginx" container.
Remark:
By default the TCP protocol is used for these connections, if we want to use the UDP protocol, we will need to specify it using the "udp" parameter as we see in the below command:
Comments