当我运行一个监听8090端口的Web应用程序容器时,
使用
docker run -p 8090: 8090 -h =%ComputerName% mycontainer 那么我可以访问 http://localhost: 8090 上的服务。
如果我使用以下命令启动容器:
docker run --net="host" -h=%ComputerName% mycontainer 那么我就无法访问 http://localhost: 8090 上的服务。
为什么会这样?
不是应该使用 -net="host",容器共享主机网络,那么为什么我不能使用 --net="host" 访问 http://localhost: 8090 呢?
使用
docker run -p 8090: 8090 -h =%ComputerName% mycontainer 那么我可以访问 http://localhost: 8090 上的服务。
如果我使用以下命令启动容器:
docker run --net="host" -h=%ComputerName% mycontainer 那么我就无法访问 http://localhost: 8090 上的服务。
为什么会这样?
不是应该使用 -net="host",容器共享主机网络,那么为什么我不能使用 --net="host" 访问 http://localhost: 8090 呢?