将公共IP分配给泊坞台 [英] Assign public IP to docker

查看:105
本文介绍了将公共IP分配给泊坞台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Linux服务器上运行的docker容器。我可以通过卷曲获得内部IP的响应如下。
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆