无法使用docker-machine添加主机

时间:2016-02-24 10:03:30

标签: docker-machine

我的公司数据中心的Linux VM上安装了docker-engine。我在我的窗户上安装了docker-machine。我想通过我的Windows机器来管理这个docker-engine。我想添加这个主机,为此我执行了以下命令:

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

但是等了几分钟后我收到了以下错误

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

我不知道自己做错了什么。

1 个答案:

答案 0 :(得分:1)

尝试使用本机SSH

不幸的是,这可能由于多种原因而发生,但由于您说您在Windows上运行,我猜测。尝试使用本机SSH客户端 - 即Docker附带的Go库,而不是ssh.exe。为此,请将--native-ssh参数传递给docker-machine

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

检查调试输出

您可以通过传递--debug参数来检查各种调试消息。当我这样做,并没有指定--native-ssh参数时,我收到了很多错误消息:

> 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 root@example.com -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...>

我的猜测是,尝试在Windows上使用反斜杠传递--generic-ssh-key并让它产生错误后,Docker(仍然)在Windows上并不像它那样完美,我想知道如果它有一些关于它调用外部SSH客户端的方式的错误。由于使用本机Go SSH客户端为我工作,我认为我的猜测是正确的,至少在我的情况下。