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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With