Docker Community Forums

Share and learn in the Docker community.

Strangeness when ssh into docker container

(Alext0) #1

I’m create my first docker container from ubuntu:latest image and install openssh-server. Container has exposed port 2201->22.
Next, I set this options:

PermitRootLogin yes
PasswordAuthentication yes

in container’s /etc/ssh/sshd_config.
After restarting sshd in container I’m trying to ssh into container to localhost:2201 from host and I get this error:

Permission denied, please try again.

Telnet to localhost to 2201 port works fine when container running.
Next, I ssh into private ip:

ssh root@

And it succeeded. Why cannot ssh to exposed port and no problems to private ip?