Search code examples
docker-machine

Unable to create new docker instances with docker-machine


I am using AWS with docker-machine to create and provision my instances. I would use this command to create a new instance:

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

About a month ago, that worked fine. I just went to create a fresh machine, and I can no longer connect to it. When I run the above command, it gets stuck on "waiting for SSH to be available..."

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...

It just hangs at that point. If I cancel the command, and check the AWS EC2 console, it suggests that it's running:

enter image description here

When I run docker-machine ls, it also suggests that it's running, but with errors:

$-> 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

I'm able to connect to the zhxw-production-2 machine (which has been running for a month). Just not the new one zhxw-production-3 one I just launched.

$-> 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.

The regenerate-certs command doesn't help either. I'm not really sure where to start debugging, because as far as I can tell, the docker-machine create command is the very beginning.


Solution

  • Turned out to be a problem with SSH to my AWS environment. I had my public IP address whitelisted, but it had changed.