[英]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的本地网络中运行)
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.