运行任务时出现 AWS ECS 错误:在您的集群中找不到容器实例 [英] AWS ECS Error when running task: No Container Instances were found in your cluster
问题描述
我正在尝试使用 ECS
将 docker
容器映像部署到 AWS
,但未创建 EC2 实例.我已经在互联网上搜索了有关为什么我收到以下错误的解释:
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:
调用 RunTask 操作时发生客户端错误 (InvalidParameterException):在您的集群中找不到容器实例."
"A client error (InvalidParameterException) occurred when calling the RunTask operation: No Container Instances were found in your cluster."
这是我的步骤:
1.将 Docker 映像从 Ubuntu 推送到我的 Amazon ECS 存储库.
1. Pushed a docker image FROM Ubuntu to my Amazon ECS repo.
2.注册一个 ECS 任务定义:
2. Registered an ECS Task Definition:
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 实例开始的!!
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:
在将 ECS 实例添加到集群之前,您必须首先转到 EC2 管理控制台并使用具有 AmazonEC2ContainerServiceforEC2Role<的 IAM 角色创建
ecs-optimized
实例/code> 附加政策
"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 theAmazonEC2ContainerServiceforEC2Role
policy attached"
这里是繁琐的:
1.转到您的EC2 仪表板,然后单击Launch Instance
按钮.
1. Go to your EC2 Dashboard, and click the Launch Instance
button.
2.在 Community AMIs
下,搜索 ecs-optimized
,然后选择最适合您的项目需求的 AMI.任何将工作.点击下一步.
2. Under Community AMIs
, Search for ecs-optimized
, and select the one that best fits your project needs. Any will work. Click next.
3.当您进入配置实例详细信息时,单击创建新的 IAM 角色链接
并创建一个名为 ecsInstanceRole
的新角色.
3. When you get to Configure Instance Details, click on the create new IAM role link
and create a new role called ecsInstanceRole
.
4.将 AmazonEC2ContainerServiceforEC2Role
策略附加到该角色.
4. Attach the AmazonEC2ContainerServiceforEC2Role
policy to that role.
5.然后,完成配置您的 ECS 实例.
注意:如果您正在创建网络服务器,您将需要创建一个安全组以允许访问端口 80.
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.
几分钟后,当实例初始化并运行时,您可以刷新您也尝试添加实例的 ECS 实例选项卡.
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屋!