我被这事弄得头破血流。这是我的装置:
我看到一个创建ECS任务的Cloudwatch日志组,但是我打印到stderr的任何东西都没有出现。

我的ECS容器具有默认的ecsInstanceRole。ecsInstanceRole有AmazonEC2ContainerServiceforEC2Role策略,如下所示:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:CreateCluster",
"ecs:DeregisterContainerInstance",
"ecs:DiscoverPollEndpoint",
"ecs:Poll",
"ecs:RegisterContainerInstance",
"ecs:StartTelemetrySession",
"ecs:UpdateContainerInstancesState",
"ecs:Submit*",
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}任务定义
{
"containerDefinitions": [
{
"dnsSearchDomains": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "torres",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "torres"
}
},
"command": [
"sleep",
"infinity"
],
"cpu": 100,
"mountPoints": [
{
"readOnly": null,
"containerPath": "/mnt/efs",
"sourceVolume": "efs"
}
],
"memoryReservation": 512,
"image": "X.dkr.ecr.us-west-2.amazonaws.com/torres-docker:latest",
"interactive": true,
"essential": true,
"pseudoTerminal": true,
"readonlyRootFilesystem": false,
"privileged": false,
"name": "torres"
}
],
"family": "torres",
"volumes": [
{
"name": "efs",
"host": {
"sourcePath": "/mnt/efs"
}
}
]
}发布于 2018-12-03 13:29:45
我想出了问题,但我不知道为什么要解决这个问题。当我将命令从sleep infinity改为只运行一段记录python script.py的代码时,CloudWatch中的日志记录就开始工作了。
在我用sleep infinity启动容器之前,使用ssh-ing进入容器并从shell启动script.py,这不是日志记录。
https://stackoverflow.com/questions/53584629
复制相似问题