如何覆盖 AWS Batch 作业中的 docker 图像?

How to override the docker image in an AWS Batch job?

在 AWS Batch 中,我试图在提交作业时覆盖作业定义中硬编码的图像。但我没有看到任何相关文档。

当我尝试在作业提交期间添加 image 字段时,我得到:

Parameter validation failed: Unknown parameter in input: "image", must be one of: jobName, jobQueue, arrayProperties, dependsOn, jobDefinition, parameters, containerOverrides, retryStrategy, timeout

Parameter validation failed: Unknown parameter in containerOverrides: "image", must be one of: vcpus, memory, command, environment

我认为这是不可能的。

image 是一个容器 属性,如 this doc 所示,它与命令、vcpus 和内存一起显示,但许多容器属性(例如作业角色 arn)未列为可覆盖在 aws batch submit-job help 文档中。

您的第二条错误消息显示了所有可以覆盖的容器属性,与文档中的属性相匹配。

--container-overrides (structure)

A list of container overrides in JSON format that specify the nameof a container in the specified job definition and the overrides itshould receive. You can override the default command for a container(that is specified in the job definition or the Docker image) with acommand override. You can also override existing environment variables (that are specified in the job definition or Docker image) ona container or add new environment variables to it with an environment override.

Shorthand 语法:

vcpus=integer,memory=integer,command=string,string,instanceType=string,environment=[{name=string,value=string},{name=string,value=string}],resourceRequirements=[{value=string,type=string},{value=string,type=string}]

JSON 语法:

{
    "vcpus": integer,
    "memory": integer,
    "command": ["string", ...],
    "instanceType": "string",
    "environment": [
        {
            "name": "string",
            "value": "string"
        }
        ...
    ],
    "resourceRequirements": [
        {
        "value": "string",
        "type": "GPU"
        }
        ...
    ]