EC2实例不存在时“ docker-machine rm”失败

nrl*_*kin 5 amazon-ec2 amazon-web-services docker docker-machine

我使用docker-machine在AWS上管理Docker节点。今天,我尝试创建一个新节点,但由于实例类型与指定的AMI之间不兼容而失败:

docker-machine create --driver amazonec2 --amazonec2-instance-type t2.micro --amazonec2-ami ami-b4a015d4 certbot-config
Running pre-create checks...
Creating machine...
(certbot-config) Launching instance...
Error creating machine: 
    Error in driver during machine creation: 
    Error launching instance: InvalidParameterCombination: Virtualization type 'hvm' is required for instances of type 't2.micro'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html
Run Code Online (Sandbox Code Playgroud)

无论如何,我都会纠正错误。我的问题是我似乎创建了一个幽灵机器。如果我运行docker-machine ls,则会得到以下信息:

NAME             ACTIVE   DRIVER      STATE   URL   SWARM   DOCKER    ERRORS
certbot-config   -        amazonec2   Error                 Unknown   MissingParameter: The request must contain the parameter InstanceId
             status code: 400, request id: 
Run Code Online (Sandbox Code Playgroud)

我无法删除,杀死它,重新启动它或设置它;每个命令从AWS驱动程序退出时都会出现400错误:

~$ docker-machine rm certbot-config
About to remove certbot-config
Are you sure? (y/n): y
Error removing host "certbot-config": unknown instance
MissingParameter: The request must contain the parameter KeyName
    status code: 400, request id: 
Run Code Online (Sandbox Code Playgroud)

如何清除该悬空实例?我有许多在docker-machine下运行的实例,所以我不想做任何大刀阔斧的事情,例如重新安装。

编辑:

也许这是另一种构架方式:docker-machine在哪里跟踪托管主机?大概我的计算机上某个地方有一个文件,上面有一个主机列表,当我运行“ docker-machine ls”时,它会在该列表中查找并ping到状态。该文件在哪里,我是否可以安全删除我知道已死的主机而又不会在其他地方留下垃圾?

Von*_*onC 4

也许另一种方式来构建这个:docker-machine 在哪里跟踪托管主机?

检查您是否有环境变量MACHINE_STORAGE_PATH

如果没有,这些 VMS 应该位于~/.docker.

您还可以看到未解决的问题 3555

使用 docker-machine 来配置Spot 实例会打开一个 Spot 请求并等待其完成。如果失败,docker-machine则退出,但现货请求仍保持开放状态,并可能稍后满足。这会导致带有活动实例的悬空点请求。

docker-machine第 226 期中讨论了 Spot 实例支持。

Spot Request来看,主要的附加参数似乎是BidRequest valid From/ToPersistent request

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/images/spot_introduction.png

在机器的上下文中,我想您可以设置request valid to = now + 2 minutes左右,此时命令可能会失败。

添加支持的 PR 为PR 942PR 1000
docker-machine rm 可能无法充分找到/提供 Spot 实例所需的额外参数。

除了从 ~/.docker/machine/machines 中删除相应的目录外,您还需要从 AWS EC2 控制台中删除相应的 EC2 密钥对。