简体   繁体   English

将Docker容器公开给公共IP

[英]Expose Docker container to public ip

I started an Ubuntu Docker container, installed ssh, run ssh with port 22 attached to it. 我启动了一个Ubuntu Docker容器,安装了ssh,并在连接了端口22的情况下运行ssh。

$ docker ps
CONTAINER ID   IMAGE          COMMAND             PORTS             
f580e36aa7f0   martin/ssh2    /usr/sbin/sshd -D   0.0.0.0:49154->22/tcp


From my server I can now ssh my container. 现在,可以从服务器上SSH容器了。 It work fine! 工作正常!

ssh root@172.17.42.1 -p 49154

But how can I ssh my container from the outside word? 但是,如何才能从外来的字眼缩进我的容器呢?
(my server is running in my local network on 192.168.1.8/24) (我的服务器在192.168.1.8/24的本地网络中运行)

  • Should I install a load balancer who redirect 192.168.1.8:2222 to 172.17.42.1:49154? 我是否应该安装将192.168.1.8:2222重定向到172.17.42.1:49154的负载均衡器?
  • Should I need pipework for that? 为此我需要管道工程吗? How? 怎么样?
  • Can someone point me in the right decision? 有人可以指出我正确的决定吗?

You should be able to connect to your container at 192.168.1.8:49154 already. 您应该已经可以在192.168.1.8:49154连接到您的容器。

Your ssh container is bind to 0.0.0.0 (=any interfaces) and port 49154 so it means container port 22 is accessible on any interface on your host at port 49154. ssh容器绑定到0.0.0.0(=任何接口)和端口49154,因此这意味着容器端口22可在主机上端口49154的任何接口上访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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