Docker Community Forums

Share and learn in the Docker community.

[Beginner] Access container by ssh

Hi guys, I am new docker guy. I took a look on N docs but they are not clear.
How can I access container from my LAN Ex:
container IP: 172.17.0.2
docker IP : 192.168.0.10
host IP: 192.168.0.20
I want ssh from 192.168.0.20(host) to 172.17.0.2(container)

That depends, if you are using a linux OS use

ssh -t user@192.168.0.10 docker exec -ti nameofcontainer /bin/bash

You can access the container with the command:

docker exec -ti container-name /bin/bash

If a ssh daemon is running inside the container it would be possible if you publish port 22 in any way.