2

I am running a Vagrant VM under Windows 7 . The Vagrant VM is running a docker container. So the configuration is :

Windows7[Vagrant[Docker]]

I want to ssh from Windows into the Docker container.

The docker container is running sshd and I can successfully ssh from Vagrant VM to Docker container.

sudo docker ps

gives:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                   NAMES
64b13daab5f2        ubuntu:12.04        "/bin/bash"         14 minutes ago      Up 14 minutes       0.0.0.0:49153->22/tcp   thirsty_morse

From the Vagrant VM:

ssh root@localhost -p 49153

works just fine. So Vagrant VM's port 49153 is forwarded to Docker container's port 22.

I've added

config.vm.network "forwarded_port", guest:49153, host:49155

to Vagrantfile so that localhost:49155 on Windows is forwarded to Vagrant VM:49153

This is where things break down. When I try to ssh from Windows to localhost:49155, I get:

ssh: connect to host localhost port 49155: Connection refused

So Windows:49155 -> Vagrant:49153 is not working. I thought that it may be a problem related to listening on a port on Vagrant VM's external ip so I've installed rinetd into Vagrant VM and I've done:

bindadress    bindport  connectaddress  connectport
0.0.0.0       49153     127.0.0.1       49153

Still no luck. What am I missing here?

1
  • 2
    Not directly related to question - but you should not need ssh in docker containers in the most cases (unless you are creating dev environment or using software which require ssh). Maybe docker exec will be enough for you?
    – ISanych
    Commented Feb 4, 2015 at 10:51

1 Answer 1

1

Ok, answering my own question. It works now. I think the most likely reason for the problem was that port 49153/55 and its neighbours is actually used by some windows services by default. I changed to mapping for ports in the Vagrant file to use 9090 for Windows and everything worked. No need to rinetd either. I've also done:

sudo docker run -v /vagrant:/opt/data -p 0.0.0.0:49153:22 -i -t ubuntu:12.04

Notice the 0.0.0.0: it may or may not be relevant but this configuration is working for me.

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