Reputation: 16513
My nginx Dockerfile:
FROM nginx:1.15.12-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx/nginx.conf /etc/nginx/conf.d
# Forward request logs to Docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
My container from my task definition for ECS:
[
{
"name": "nginx",
"image": "<ECR REPO HERE>",
"networkMode": "awsvpc",
"essential": true,
"portMappings": [
{
"containerPort": 80,
"protocol": "http"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "mygroup",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "nginx"
}
},
"essential": true
}
]
Yet when the task is deployed, it fails, and in CloudWatch I see the following:
I'm very new to ECS / Cloudwatch. How can I see the NGINX errors from the container failing?
Upvotes: 5
Views: 4280
Reputation: 963
ECS_Execution_Role_Policy
. it should contains logs
permission. like :{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
ecs_agent
's config for awslogs
driver.this config file path is /etc/ecs/ecs.config
in host. this file should be like :
ECS_CLUSTER=test_ecs_cluster
ECS_AVAILABLE_LOGGING_DRIVERS=["awslogs","json-file"]
See :
Here's a document
Upvotes: 3