5

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:

enter image description here

I'm very new to ECS / Cloudwatch. How can I see the NGINX errors from the container failing?

lollercoaster
  • 15,969
  • 35
  • 115
  • 173

1 Answers1

3
  1. you should check 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": "*"
        }
    ]
}
  1. you should configure 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

GNOKOHEAT
  • 923
  • 6
  • 18
  • thanks. 1. is "ECS_Execution_Role_Policy" one of the policies attached to the role associated with service that runs the task with nginx in AWS ECS? 2. what is `eds_agent`? where can i find it? – Naveen Reddy Marthala Jul 27 '22 at 10:12