Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No public port '22/tcp' published for test_sshd

Tags:

docker

I'm trying to execute this:

https://hub.docker.com/r/rastasheep/ubuntu-sshd/

Namely, I run:

sudo docker run -d -P --name test_sshd rastasheep/ubuntu-sshd:16.04 

Then

sudo docker port test_sshd 22

I can see something like:

0.0.0.0:49154

And I can run:

ssh root@localhost -p 49154 

But as soon as I restart my computer, I see this:

sudo docker port test_sshd 22
Error: No public port '22/tcp' published for test_sshd

Could you give me a kick here?

like image 813
Michael Avatar asked Dec 12 '25 04:12

Michael


1 Answers

The option -P binds a port dynamically and randomly, that's why you need another step to associate a port, using docker port. I would use instead a free static port to access ssh port to this container :

docker container run -d -p 2222:22 --name test_sshd rastasheep/ubuntu-sshd:16.04
ssh root@localhost -p 2222

This port setting persists when dockerd is restarted.

like image 198
Serge Hartmann Avatar answered Dec 13 '25 19:12

Serge Hartmann