无法使用docker-machine添加主机

5

我在公司的数据中心安装了Docker-engine,它运行在Linux虚拟机上。然后我在Windows机器上安装了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

我不知道我做错了什么。


不确定是否完全是这个问题,但我必须像这样指定我使用的ssh密钥 --generic-ssh-key ~/.ssh/custom_rsa - Jared Mackey
有人找到这个问题的解决方案了吗?我被卡在这里,遇到了同样的问题。 - Tushar Gandhi
1个回答

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客户端对我有效,我认为我的猜测至少在我的情况下是正确的。


+1....这让我非常疯狂,而你却一针见血地指出了问题!添加那个神奇的开关后,我的所有SSH错误都消失了。而且,我使用的是WIN7x64......但是......我还使用Git进行大量的开发,并安装了SSHD服务来支持它们......所以在像我这样的情况下,“本地”开关必须简单地指示docker使用我的附加SSHd服务,这反过来当然会立即无故障地工作。 - Collin Chaffin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接