无法使用docker-machine创建新的docker实例

问题描述

我正在将AWS与docker-machine一起使用来创建和设置实例。我将使用此命令创建一个新实例:

docker-machine create --driver amazonec2 --amazonec2-instance-type "t2.micro" --amazonec2-security-group zhxw-production-sg zhxw-production-3

大约一个月前,效果很好。我只是去创建一台新机器,而我无法再连接到它。当我运行上述命令时,它卡在了“等待SSH可用...”

Running pre-create checks...
Creating machine...
(zhxw-production-3) Launching instance...
Waiting for machine to be running,this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...

它只是挂在那一点上。如果我取消该命令并检查AWS EC2控制台,则表明它正在运行:

enter image description here

当我运行docker-machine ls时,它也表明它正在运行,但是有错误

$-> docker-machine ls
NAME                ACTIVE   DRIVER      STATE     URL                         SWARM   DOCKER      ERRORS
zhxw-production-2   -        amazonec2   Running   tcp://3.86.xxx.xxx:2376             v19.03.12   
zhxw-production-3   -        amazonec2   Running   tcp://54.167.xxx.xxx:2376           UnkNown     Unable to query docker version: Cannot connect to the docker engine endpoint

我能够连接到zhxw-production-2机器(已经运行了一个月)。只是不是我刚刚推出的新产品zhxw-production-3。

$-> docker-machine env zhxw-production-3
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "54.167.123.108:2376": dial tcp 54.167.123.108:2376: connect: connection refused
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.

regenerate-certs命令也无济于事。我不太确定从哪里开始调试,因为据我所知,docker-machine create命令的最开始。

解决方法

原来是我的AWS环境中的SSH问题。我的公共IP地址已列入白名单,但是已经更改了。