简体   繁体   中英

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.

--network host允许容器访问整个主机网络,而-p 80:80将容器的端口 80 映射到主机的端口 80

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM