Reputation: 23
What is the difference between starting Docker these ways?
docker --net = host
docker -p 8200:8200 -p 34016:34016
Upvotes: 2
Views: 161
Reputation: 32176
The first one shares the net namespace between the docker container and the host.
For example, a nethogs container launched without --net=host
will not display much, see
see https://hub.docker.com/r/k3ck3c/nethogs_git/
if I do not put --net=host
the docker container does not see any network card, so I get
No devices to monitor. Use '-a' to allow monitoring loopback interfaces or devices that are not up/running
It wil be the same with a OpenVPN container
you will notice that the pid and net namespaces of the host will be available to the container, in the command
docker run -it --rm --net=host --pid=host k3ck3c/nethogs_git wlan0
The second says that the port 8200 of the container will be published on the port 8200 of the host, and the same for the port 34016. To be more specific,
-p 9000:10000
means the port 10000 of the container will be published on the port 9000 of the host.
Upvotes: 1