运行任务时出现AWS ECS错误:在集群中未找到容器实例 [英] AWS ECS Error when running task: No Container Instances were found in your cluster

查看:344
本文介绍了运行任务时出现AWS ECS错误:在集群中未找到容器实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ECSdocker容器映像部署到AWS,但是未创建EC2实例.我在互联网上搜寻了有关为什么收到以下错误的解释:

调用RunTask操作时发生客户端错误(InvalidParameterException):在群集中未找到容器实例."

这是我的步骤:

1.将Docker映像从Ubuntu推送到我的Amazon ECS存储库中.

2.注册了ECS任务定义:

aws ecs register-task-definition --cli-input-json file://path/to/my-task.json 

3.执行任务:

aws ecs run-task --task-definition my-task

但是,它失败了.

这是我的任务:

{
  "family": "my-task",
  "containerDefinitions": [
    {
        "environment": [],
        "name": "my-container",
        "image": "my-namespace/my-image",
        "cpu": 10,
        "memory": 500,
        "portMappings": [
            {
                "containerPort": 8080,
                "hostPort": 80
            }
        ],
        "entryPoint": [
            "java",
            "-jar",
            "my-jar.jar"
        ],
        "essential": true
    }
  ]
}

我也尝试过使用管理控制台来配置集群和服务,但是却遇到了同样的错误. 如何将群集配置为具有ec2实例,我需要使用哪种容器实例? 我认为整个过程都是从创建EC2实例开始!

解决方案

经过几个小时的调查,我发现了这一点.亚马逊,如果您正在侦听,则在创建集群或向集群添加实例时,应在管理控制台中的某个位置声明此状态:

在将ECS实例添加到群集之前,您必须首先进入EC2管理控制台并创建带有附加了AmazonEC2ContainerServiceforEC2Role策略的IAM角色的ecs-optimized实例"

这是难忘的事情:

1.转到您的 EC2仪表板,然后单击Launch Instance按钮./p>

2.在Community AMIs下,搜索ecs-optimized,然后选择最适合您的项目需求的一个.任何都可以.单击下一步.

3.当您进入配置实例详细信息"时,单击create new IAM role link并创建一个名为ecsInstanceRole的新角色.

4.将AmazonEC2ContainerServiceforEC2Role策略附加到该角色.

5.然后,完成配置ECS实例.
注意::如果要创建Web服务器,则需要创建一个securityGroup来允许访问端口80.

几分钟后,实例初始化并运行后,您可以刷新ECS实例选项卡,您也尝试添加实例.

Im trying to deploy a docker container image to AWS using ECS, but the EC2 instance is not being created. I have scoured the internet looking for an explanation as to why I'm receiving the following error:

"A client error (InvalidParameterException) occurred when calling the RunTask operation: No Container Instances were found in your cluster."

Here are my steps:

1. Pushed a docker image FROM Ubuntu to my Amazon ECS repo.

2. Registered an ECS Task Definition:

aws ecs register-task-definition --cli-input-json file://path/to/my-task.json 

3. Ran the task:

aws ecs run-task --task-definition my-task

Yet, it fails.

Here is my task:

{
  "family": "my-task",
  "containerDefinitions": [
    {
        "environment": [],
        "name": "my-container",
        "image": "my-namespace/my-image",
        "cpu": 10,
        "memory": 500,
        "portMappings": [
            {
                "containerPort": 8080,
                "hostPort": 80
            }
        ],
        "entryPoint": [
            "java",
            "-jar",
            "my-jar.jar"
        ],
        "essential": true
    }
  ]
}

I have also tried using the management console to configure a cluster and services, yet I get the same error. How do I configure the cluster to have ec2 instances, and what kind of container instances do I need to use? I thought this whole process was to create the EC2 instances to begin with!!

解决方案

I figured this out after a few more hours of investigating. Amazon, if you are listening, you should state this somewhere in your management console when creating a cluster or adding instances to the cluster:

"Before you can add ECS instances to a cluster you must first go to the EC2 Management Console and create ecs-optimized instances with an IAM role that has the AmazonEC2ContainerServiceforEC2Role policy attached"

Here is the rigmarole:

1. Go to your EC2 Dashboard, and click the Launch Instance button.

2. Under Community AMIs, Search for ecs-optimized, and select the one that best fits your project needs. Any will work. Click next.

3. When you get to Configure Instance Details, click on the create new IAM role link and create a new role called ecsInstanceRole.

4. Attach the AmazonEC2ContainerServiceforEC2Role policy to that role.

5. Then, finish configuring your ECS Instance.
NOTE: If you are creating a web server you will want to create a securityGroup to allow access to port 80.

After a few minutes, when the instance is initialized and running you can refresh the ECS Instances tab you are trying to add instances too.

这篇关于运行任务时出现AWS ECS错误:在集群中未找到容器实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆