Docker-machine generic driver to remote host using SSH?

I’m exploring how to move a multi container project using docker-compose to a more distributed solution and while doing so, my first step was testing docker-machine (0.5.0 (04cfa58)) to try and address remote docker daemons via ssh…

While I’m able to use the VirtualBox driver to spin up a “local” boot2docker instance, I’m unable to connect via the generic driver to a normal full fledged remote Ubuntu host.

Here is what I’m getting:
(I can ssh to 192.168.10.10 as root no problem with ssh keys)

>docker-machine  create --driver generic --generic-ip-address 192.168.10.10 --generic-ssh-user root --generic-ssh-key ~/.ssh/id_rsa test
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Detecting operating system of created instance...
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Provisioning created instance...
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Copying certs to the local machine directory...
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Copying certs to the remote machine...
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Setting Docker configuration on the remote daemon...
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Enter passphrase for key '/home/user/.docker/machine/machines/test/id_rsa':
Error creating machine: Error running provisioning: Unable to verify the Docker daemon is listening: Maximum number of retries (5) exceeded

But it does seem to eventually create something in /etc/docker/, even though I have to paste the password so many times (so they’re all correct tries!), but nothing much else (beside changing hosts and hostname if I don’t put the machine’s current hostname).

or

>docker-machine --native-ssh create --driver generic --generic-ip-address 192.168.10.10 --generic-ssh-user root --generic-ssh-key ~/.ssh/id_rsa test
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...

If I expose a docker daemon to a tcp port I’m also able to address it from the other machine with -H, but that’s not very secure if it’s possible …
Any idea what I’m doing wrong?
Thanks!

1 Like

Try adding the key to ssh-agent (ssh-add ~/.ssh/id_rsa) and not specifying an ssh key when you create the VM. It looks like docker-machine is not playing well with ssh’s interactive password prompt.

1 Like

Funny I just got a swarm running yesterday but with insecure key… But thanks, indeed, using the agent but NOT specifying the key seems to have worked! :smile:

I’ll add this solution here: https://github.com/docker/machine/issues/1357

Thanks!

Thank you so much it works now :slight_smile:

siju@vms-1:~$ ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
siju@vms-1:~$ docker-machine create --driver generic --generic-ip-address=192.168.1.9 --generic-ssh-user rancher rancher
Running pre-create checks…
Creating machine…
(rancher) No SSH key specified. Assuming an existing key at the default location.
Waiting for machine to be running, this may take a few minutes…
Detecting operating system of created instance…
Waiting for SSH to be available…
Detecting the provisioner…
Provisioning with rancheros…
Copying certs to the local machine directory…
Copying certs to the remote machine…
Setting Docker configuration on the remote daemon…
Checking connection to Docker…
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env rancher

saved my life, thanks a lot.