【问题标题】:AWS ECS FARGATE - unable to pull image from docker private repositoryAWS ECS FARGATE - 无法从 docker 私有存储库中提取图像
【发布时间】:2021-12-10 19:18:06
【问题描述】:

我正在尝试使用从我的私有 Docker 存储库中提取图像的任务创建一个 ECS 集群。 我在 AWS SecretsManager 中创建了一个密钥。 我使用以下参数创建了策略。

  "Action": "secretsmanager:GetSecretValue",
  "Resource": "arn:aws:secretsmanager:eu-west-1:123456789:secret:docker_private_repo-123456"

我向 ECS 任务定义过程创建的“ecsTaskExecutionRole”添加了新策略。

但不幸的是,任务总是停止。

我尝试在以下教程中做所有事情。 https://docs.aws.amazon.com/AmazonECS/latest/developerguide/private-auth.html https://aws.amazon.com/blogs/compute/introducing-private-registry-authentication-support-for-aws-fargate/

我收到了这个错误。

“已停止原因ResourceInitializationError:无法提取机密或注册表身份验证:执行资源检索失败:无法从asm获取注册表身份验证:服务调用已重试1次:无法从asm解组授权数据的机密值:我……”

发射类型 FARGATE 平台版本 1.4.0

谁能帮帮我,拜托。 谢谢。。

任务定义:

    {
  "ipcMode": null,
  "executionRoleArn": "arn:aws:iam::123456789:role/ecsTaskExecutionRole",
  "containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "environmentFiles": null,
      "logConfiguration": {
        "logDriver": "awslogs",
        "secretOptions": null,
        "options": {
          "awslogs-group": "/ecs/WebFTask",
          "awslogs-region": "eu-west-1",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        }
      ],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [],
      "resourceRequirements": null,
      "ulimits": null,
      "repositoryCredentials": {
        "credentialsParameter": "arn:aws:secretsmanager:eu-west-1:123456789:secret:docker_private_repo-123456"
      },
      "dnsServers": null,
      "mountPoints": [],
      "workingDirectory": null,
      "secrets": null,
      "dockerSecurityOptions": null,
      "memory": null,
      "memoryReservation": 512,
      "volumesFrom": [],
      "stopTimeout": null,
      "image": "docker.io/username/imageName:latest",
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": null,
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "systemControls": null,
      "privileged": null,
      "name": "WebContariner"
    }
  ],
  "placementConstraints": [],
  "memory": "2048",
  "taskRoleArn": "arn:aws:iam::123456789:role/ecsTaskExecutionRole",
  "compatibilities": [
    "EC2",
    "FARGATE"
  ],
  "taskDefinitionArn": "arn:aws:ecs:eu-west-1:123456789:task-definition/WebFTask:6",
  "family": "WebFTask",
  "requiresAttributes": [
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.execution-role-awslogs"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.private-registry-authentication.secretsmanager"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.task-iam-role"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
    },
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "ecs.capability.task-eni"
    }
  ],
  "pidMode": null,
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "networkMode": "awsvpc",
  "cpu": "1024",
  "revision": 6,
  "status": "ACTIVE",
  "inferenceAccelerators": null,
  "proxyConfiguration": null,
  "volumes": []
}

ecsTaskExecutionRole:

政策 1:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ecr:GetAuthorizationToken",
                "ecr:BatchCheckLayerAvailability",
                "ecr:GetDownloadUrlForLayer",
                "ecr:BatchGetImage",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}

政策 2:

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "secretsmanager:GetSecretValue",
            "Resource": "arn:aws:secretsmanager:eu-west-1:123456789:secret:docker_private_repo-123456c"
        }
    ]
}

【问题讨论】:

  • 您的任务定义到底是什么? ecsTaskExecutionRole 中的权限是什么?遗憾的是,您的问题缺乏细节。
  • @Marcin 感谢您的即时回复。我编辑了这个问题。我希望它有所帮助。

标签: amazon-web-services task amazon-ecs fargate


【解决方案1】:

您的任务定义显示缺少任务角色

"taskRoleArn": null,

似乎你创建了它,但你还没有将它分配给任务。

【讨论】:

  • 我将其保留为默认值。它是什么灵魂?有哪些政策?
  • @ŞamilAydoğan 默认为空。只需将您的executionRoleArn 用作taskRoleArn
  • 谢谢。我编辑了问题。如您所述,更改了 taskRoleArn。但没有帮助。它仍然以同样的原因停止。
猜你喜欢
  • 2018-05-20
  • 2019-03-25
  • 2021-01-05
  • 2023-03-07
  • 2017-07-05
  • 2020-06-08
  • 1970-01-01
  • 1970-01-01
  • 2020-07-05
相关资源
最近更新 更多