将公共IP分配给泊坞台 [英] Assign public IP to docker
问题描述
curl http://172.17.0.2:8080/greeting?name=jo
这个Linux服务器的公共IP是199.231.191.106。如何使用这个公共IP访问docker应用程序?
运行Web服务器的docker容器很可能会 EXPOSE一个端口。
您可以通过使用
docker inspect --format ='{{范围$ p,$ conf:= .Config.ExposedPorts}} {{$ p}} {{end}}'< container>
运行容器时,需要将EXPOSE的端口映射到Linux主机,订单可以访问所述端口。
请参阅码头运行-p hostPort:containerPort
docker run -p 80:8080 ...
I have a docker container running on Linux server. I can get the response by a curl to the internal IP as below. curl http://172.17.0.2:8080/greeting?name=jo
This Linux server's public IP is 199.231.191.106. How can I access the docker application by using this public IP?
A docker container running a web server is likely to EXPOSE a port.
You can see it by inspecting its image (or the running container directly) with
docker inspect --format='{{range $p, $conf := .Config.ExposedPorts}} {{$p}} {{end}}'<container>
When you run your container, you need to map that EXPOSE'd port to the Linux host, in order for said port to be accessible.
See docker run -p hostPort:containerPort
docker run -p 80:8080 ...
这篇关于将公共IP分配给泊坞台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!