ECS 无效引用格式错误

ECS invalid reference format error

我尝试通过 运行 任务(由任务定义定义)使用 Amazon ECS 部署和 运行 一个简单的 Dockerized Ruby 后端,但它未能 运行 我的命令并返回了这个错误:

CannotPullContainerError: API error (400): invalid reference format

我已经尝试 运行 echo "Hello" 的一个小入口点命令,但无论它是 exec 形式还是 shell 形式,它都会返回相同的错误。我尝试在我的本地终端中 运行 这个命令 运行 很好:

$ docker-compose run job echo 'HELLO_WORLD'
HELLO_WORLD

这是我的集群任务的详细信息部分中显示的错误消息:

Status reason   CannotPullContainerError: API error (400): invalid reference format
  Entry point   ["echo","HELLO"]

这是我的任务定义JSON(出于安全原因隐藏某些信息):

{
    "executionRoleArn": null,
    "containerDefinitions": [
        {
            "dnsSearchDomains": null,
            "logConfiguration": null,
            "entryPoint": [
                "echo",
                "HELLO"
            ],
            "portMappings": [],
            "command": [],
            "linuxParameters": null,
            "cpu": 0,
            "environment": [
                {
                    "name": "RAILS_ENV",
                    "value": "production"
                }
            ],
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [],
            "workingDirectory": null,
            "dockerSecurityOptions": null,
            "memory": 7000,
            "memoryReservation": null,
            "volumesFrom": [],
            "image": "<ecs_image_arn>",
            "disableNetworking": false,
            "healthCheck": null,
            "essential": true,
            "links": null,
            "hostname": null,
            "extraHosts": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": null,
            "privileged": null,
            "name": "<name>"
        }
    ],
    "memory": null,
    "taskRoleArn": "arn:aws:iam::<id>:role/<name>",
    "family": "<test-cluster>",
    "requiresCompatibilities": [
        "EC2"
    ],
    "networkMode": null,
    "cpu": null,
    "volumes": [],
    "placementConstraints": []
}

更改入口点以使用命令也不起作用。

Status reason   CannotPullContainerError: API error (400): invalid reference format
    Command ["echo","HELLO"]

我是否遗漏了使简单的 echo 命令起作用的任何配置?

"Invalid reference format"表示docker试图解析的图片名称无效。在您的日志中:

   "image": "<ecs_image_arn>",

图片名称确实无效,需要替换为有效的图片名称。如果出于隐私考虑,您在此问题中已替换该字符串,则删除的部分就是您存在错误的地方。

确保使用存储库 URI而不是 ARN(如果使用 ECR 映像)。 Some AWS documentation(请参阅“未找到图像”部分)将 ARN 描述为有效值,但它似乎不起作用。