简体   繁体   中英

Expose Docker container to public ip

I started an Ubuntu Docker container, installed ssh, run ssh with port 22 attached to it.

$ 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. It work fine!

ssh root@172.17.42.1 -p 49154


(my server is running in my local network on 192.168.1.8/24)

  • Should I install a load balancer who redirect 192.168.1.8:2222 to 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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