我在尝试使用 ECS 集群中的任务定义创建服务时遇到此错误: 部署 NoteAppService 时遇到错误。资源处理程序消息:“操作‘ECS 部署断路器已触发’遇到错误。” (请求令牌:a9b4170a-b382-355d-0dc5-ae55cc25d314,HandlerErrorCode:GeneralServiceException)
因此,我无法在集群中创建服务。我已经尝试了多次,但错误仍然存在。 由于缺乏经验,我不确定具体的错误以及如何解决它。 这是我的任务定义文件:
{
"taskDefinitionArn": "arn:aws:ecs:us-east-1:755204033406:task-definition/NoteappTaskDefin:1",
"containerDefinitions": [
{
"name": "Container1",
"image": "public.ecr.aws/d4a1q9y6/note_app_public_repo",
"cpu": 0,
"portMappings": [
{
"name": "container1-3000-tcp",
"containerPort": 3000,
"hostPort": 3000,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"ulimits": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/ecs/NoteappTaskDefin",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
}
}
],
"family": "NoteappTaskDefin",
"executionRoleArn": "arn:aws:iam::755204033406:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"revision": 1,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"EC2"
],
"cpu": "1024",
"memory": "3072",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2023-08-22T09:37:03.162Z",
"registeredBy": "arn:aws:iam::755204033406:root",
"tags": []
}
此问题通常归因于启动容器失败。请检查日志以获取更多见解。
此外,请考虑在
entryPoint
部分中指定 command
和 containerDefinitions
参数。
{
"taskDefinitionArn": "arn:aws:ecs:us-east-1:755204033406:task-definition/NoteappTaskDefin:1",
"containerDefinitions": [
{
"name": "Container1",
"image": "public.ecr.aws/d4a1q9y6/note_app_public_repo",
"cpu": 0,
"portMappings": [
{
"name": "container1-3000-tcp",
"containerPort": 3000,
"hostPort": 3000,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"entryPoint": [
"sh",
"-c"
],
"command": [
"your command here"
]
}
]
[…]
}