Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to add host using docker-machine

I have docker-engine installed on a linux VM on my company data center. I installed docker-machine on my windows. I want to manage this docker-engine through my windows machine. I want to add this host and for that I executed the following command:

docker-machine create -d generic --generic-ip-address 10.51.227.5 --generic-ssh-port 22 --generic-ssh-user root compute

But I am getting the following error after waiting for couple of minutes

Running pre-create checks...
Creating machine...
(compute) No SSH key specified. Connecting to this machine now and in the future will require the ssh agent to contain the appropriate key.
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Error creating machine: Error detecting OS: Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded

I don't know what I am doing wrong.

like image 323
Gourav Singla Avatar asked Nov 08 '22 19:11

Gourav Singla


1 Answers

Try using native SSH

Unfortunately, this can happen for multiple reasons, but since you say you're running on Windows, I have a guess. Try using the native SSH client - that is, the Go library that ships with Docker, rather than ssh.exe. To do so, pass the --native-ssh argument to docker-machine:

docker-machine --native-ssh create --driver generic --generic-ip-address example.com ExampleMachine

Examining debug output

You can examine various debugging messages by passing the --debug argument. When I did that, and did not specify the --native-ssh argument, I got lots of error messages:

> docker-machine create --driver generic --generic-ip-address example.com ExampleMachine
<...snip...>
Waiting for SSH to be available...
Getting to WaitForSSH function...
(apsylania) Calling .GetSSHHostname
(apsylania) Calling .GetSSHPort
(apsylania) Calling .GetSSHKeyPath
(apsylania) Calling .GetSSHKeyPath
(apsylania) Calling .GetSSHUsername
Using SSH client type: external
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none [email protected] -o IdentitiesOnly=yes -i C:\Users\MyAccount\.docker\machine\machines\ExampleMachine\id_rsa -p 22] C:\Program Files\OpenSSH-Win64\ssh.exe <nil>}
About to run SSH command:
exit 0
SSH cmd err, output: exit status 255:
Error getting ssh command 'exit 0' : ssh command error:
command : exit 0
err     : exit status 255
output  :
Getting to WaitForSSH function...
<...snip...>

My guess, after trying to pass --generic-ssh-key with backslashes on Windows and having it produce an error, was that Docker (still) isn't quite as polished on Windows as it could be, and I wondered if there was something buggy about the way it calls out to an external SSH client. Since using the native Go SSH client worked for me, I think that my guess was correct, at least for my case.

like image 188
Micah R Ledbetter Avatar answered Dec 25 '22 05:12

Micah R Ledbetter