Connection refused when trying to SSH into Docker containers. But port 22 is not blocked. Pings work

Hello, you use root user to acess container?

If yes, you need the change permission sshd_config

nano /etc/ssh/sshd_config

PermitRootLogin without-password
change to
PermitRootLogin yes

service ssh restart

and try again.