2

Real docker noob here, trying to get an ubuntu container that can be accessed via SSH.

I'm using an image using this dockerfile and building & running it with "docker build -t sshable ~/PATH/" and "docker run --name test -t sshable". I can ssh out to the host and a VM on it just fine as well as other containers running the same image. However, when I try to "ssh IP_ADDR" from the host where IP_ADDR is the IP address given as "inet addr" in eth0 for the container (when using ifconfig) it can't, saying "ssh: connect to host IP_ADDR port 22: Network is unreachable." I can also ping out from the containers, but not into them as it times out. Is the host not on the bridge network and if so how do I get it on?

1 Answer 1

0

You need to expose the inbound port (22) to the container from the host to connect via ssh:

docker run -it -P 22:22 --name test sshable

There are easier and better way to gain access into a container though:

docker run -it --name test sshable /bin/bash

If the container is running you can connect to it via:

docker exec -it test /bin/bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.