我尝试通过运行一个Task(由Task Definition定义)来使用Amazon ECS部署和运行一个简单的Dockerized Ruby后端,但是它无法运行我的命令并返回此错误:
CannotPullContainerError:API错误(400):无效的引用格式
我尝试运行echo "Hello"
的一个较小的Entrypoint命令,但是无论是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": []
}
更改entryPoint以使用命令也无法正常工作。
Status reason CannotPullContainerError: API error (400): invalid reference format
Command ["echo","HELLO"]
我是否缺少任何配置来使简单的echo
命令起作用?
答案 0 :(得分:3)
“无效的引用格式”表示docker试图解析的映像名称无效。在您的日志中:
"image": "<ecs_image_arn>",
图像名称确实无效,需要用有效的图像名称替换。如果您出于隐私目的在此问题中已替换了该字符串,则删除的部分就是您的错误所在。
答案 1 :(得分:0)
确保使用存储库 URI ,而不使用ARN(如果使用ECR图像)。 Some AWS documentation(请参阅“找不到图像”部分)将ARN描述为有效值,但似乎不起作用。