Search code examples
amazon-ec2docker-machine

AWS EC2 docker machine with amazonec2 driver - Host already exists


The following command should create a new docker machine on a shiny new Amazon EC2 instance:

docker-machine \
      --storage-path /path/to/folder/docker_machines \
      create \
      --driver amazonec2 \
      --amazonec2-access-key <my key> \
      --amazonec2-secret-key <my secret> \
      --amazonec2-vpc-id <my vpc>  \
      --amazonec2-region <my region> \
      --amazonec2-zone <my AZ> \
      --amazonec2-security-group <existing Sec Grp> \
      --amazonec2-ami ami-da05a4a0 \
      --amazonec2-ssh-keypath /path/to/private/key \
     --engine-install-url=https://web.archive.org/web/20170623081500/https://get.docker.com \
     awesome-new-docker-machine

I ran this command once, and encountered a legitimate problem (bad path to private key). Once I fixed that and ran the command again, I get this error:

Host already exists: "awesome-new-docker-machine"

However, I can't find this docker machine anywhere:

$ docker-machine ls
NAME     ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS

I even tried a docker-machine rm and docker-machine kill just for giggles. No difference.

I can't see a new EC2 instance on Amazon having been created from the first, erroneous run of the command.

How can I "clean up" whatever's existing (somewhere) so I can recreate the machine correctly?


Solution

  • So, it turns out that the first run of the command created some initial artifacts in a new folder awesome-new-docker-machine under /path/to/folder/docker_machines.

    Deleting this folder and trying again worked perfectly.