jisoo
jisoo

Reputation: 35

is there a diffrence between port mapping and host network?

i have two commands:

  1. docker run --name some-nginx -d -p 80:80 nginx
  2. docker run --name some-nginx -d --network host nginx

In my understanding nginx will show default page on my computer's port 80

In my host machine localhost:80 works perfectly same: gives me default nginx page.

BUT when i try it on other LAN machine, if i type my-host-machinip:80, first one works but second one gives me "connection refuesed"

i can not understand why it happend.

Upvotes: 0

Views: 113

Answers (1)

Oblivion
Oblivion

Reputation: 7374

--network host allows the container to have access to the whole host network while the -p 80:80 maps port 80 of the container to the port 80 of host

Upvotes: 2

Related Questions