ECS TaskDefinition volumesFrom does not appear to share ECS volume

Viewed 21

I have two docker containers.

Docker container A: Runs an application and nginx. nginx outputs logs to /var/logs/nginx/ app outputs logs to /var/logs/app/

Docker container B is a cloudwatch-agent this is defined as a "side car" container wihtin the same task def as container A.

I am trying to use "volumesFrom" to mount the local volume of app with cloudwatch.

"volumesFrom": [
    {
      "ReadOnly" : true,
      "SourceContainer": "app"
    }
],

However the CloudWatch agent container cannot seem to find the logs I have configured it to look for. (It does deploy successfully)

{
  "name": "cloudwatch-agent",
  "image": "public.ecr.aws/cloudwatch-agent/cloudwatch-agent:latest",
  "environment": [
    {
      "name": "CW_CONFIG_CONTENT",
      "value": "{\"logs\": { \"logs_collected\": { \"files\": { \"collect_list\": [ { \"file_path\": \"/var/log/nginx/access.log\", \"log_group_name\": \"/drupal/nginx-access\", \"log_stream_name\": \"ecs\"}]}}}}"
    }
  ],
  "volumesFrom": [
    {
      "ReadOnly" : true,
      "SourceContainer": "drupal"
    }
  ],
  "logConfiguration": {
      "logDriver": "awslogs",
      "options": {
        "awslogs-create-group": "True",
        "awslogs-group": "/ecs/ecs-cwagent-fargate",
        "awslogs-region": "${region}",
        "awslogs-stream-prefix": "ecs"
      }
  }
}]

What am I doing wrong?

0 Answers
Related