Docker Community Forums

Share and learn in the Docker community.

Ssh to the outside from inside the docker container


(Chrisdebug) #1

Does anyone know how to ssh outside from inside a docker container?


(Chrisdebug) #2

Here are a few more details:

Running on Mac OS.
Trying to ssh to a completely different server that is not on my host and is not using docker.

Dockerfile:

FROM ubuntu:14.04
RUN sudo apt-get install ssh -y
RUN mkdir --mode=700 /root/.ssh
COPY my_key.id_dsa /root/.ssh/
RUN chmod 600 /root/.ssh/my_key.id_rsa

I’ve also noticed that from my local system, the IP that ssh connects to is:
debug1: Connecting to mydomain.com [10.x.x.x] port 22.

but the IP in the docker container goes to:
debug1: Connecting to mydomain.com [208.x.x.x] port 22.

Why are the IP addresses different? When I use the 10.x.x.x address directly in the container, ssh works fine.


(Chrisdebug) #3

I just started over. Recreated everything and now it works.

I don’t really know why. My guess is that the networking gets affected when I move between home and work.