json - 提交AWS Batch作业时出现CannotStartContainerError

标签 json amazon-web-services docker jobs amazon-ecs

AWS Batch中,我有一个job definitionjob queuecompute environment在哪里执行我的AWS Batch jobs
提交作业后,我在失败的列表中找到此错误:

Status reason
Essential container in task exited
Container message
CannotStartContainerError: API error (404): oci runtime error: container_linux.go:247: starting container process caused "exec: \"/var/application/script.sh --file= --key=. 

cloudwatch logs中,我有:
container_linux.go:247: starting container process caused "exec: \"/var/application/script.sh --file=Toulouse.json --key=out\": stat /var/application/script.sh --file=Toulouse.json --key=out: no such file or directory"

我已经指定了包含所有脚本的正确docker镜像(我们已经使用过并且可以使用),而且我不知道错误是从哪里来的。
任何建议都非常感谢。

docker 文件是这样的:
# Pull base image.
FROM account-id.dkr.ecr.region.amazonaws.com/application-image.base-php7-image:latest

VOLUME /tmp
VOLUME /mount-point

RUN chown -R ubuntu:ubuntu /var/application

# Create the source directories
USER ubuntu
COPY application/ /var/application

# Register aws profile
COPY data/aws /home/ubuntu/.aws

WORKDIR /var/application/
ENV COMPOSER_CACHE_DIR /tmp
RUN composer update -o && \
    rm -Rf /tmp/*

这是Job Definition:
{
    "jobDefinitionName": "JobDefinition",
    "jobDefinitionArn": "arn:aws:batch:region:accountid:job-definition/JobDefinition:25",
    "revision": 21,
    "status": "ACTIVE",
    "type": "container",
    "parameters": {},
    "retryStrategy": {
        "attempts": 1
    },
    "containerProperties": {
        "image": "account-id.dkr.ecr.region.amazonaws.com/application-dev:latest",
        "vcpus": 1,
        "memory": 512,
        "command": [
            "/var/application/script.sh",
            "--file=",
            "Ref::file",
            "--key=",
            "Ref::key"
        ],
        "volumes": [
            {
                "host": {
                    "sourcePath": "/mount-point"
                },
                "name": "logs"
            },
            {
                "host": {
                    "sourcePath": "/var/log/php/errors.log"
                },
                "name": "php-errors-log"
            },
            {
                "host": {
                    "sourcePath": "/tmp/"
                },
                "name": "tmp"
            }
        ],
        "environment": [
            {
                "name": "APP_ENV",
                "value": "dev"
            }
        ],
        "mountPoints": [
            {
                "containerPath": "/tmp/",
                "readOnly": false,
                "sourceVolume": "tmp"
            },
            {
                "containerPath": "/var/log/php/errors.log",
                "readOnly": false,
                "sourceVolume": "php-errors-log"
            },
            {
                "containerPath": "/mount-point",
                "readOnly": false,
                "sourceVolume": "logs"
            }
        ],
        "ulimits": []
    }
}

在Cloudwatch日志流/ var / log / docker中:
time="2017-06-09T12:23:21.014547063Z" level=error msg="Handler for GET /v1.17/containers/4150933a38d4f162ba402a3edd8b7763c6bbbd417fcce232964e4a79c2286f67/json returned error: No such container: 4150933a38d4f162ba402a3edd8b7763c6bbbd417fcce232964e4a79c2286f67" 

最佳答案

该错误是因为命令格式错误。我正在使用boto3通过lambda函数(python 2.7)提交作业,命令的语法应如下所示:

'command' : ['sudo','mkdir','directory']

希望它能帮助到别人。

关于json - 提交AWS Batch作业时出现CannotStartContainerError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44440074/

相关文章:

docker - 如何将Dockerfile中的ENV命令集替换为其他文件,以供重用?

json - 使用 Alamofire API Rest 发送空数组

ios - 使用 Swift 返回具有自定义数据类型的 JSON 数据时遇到问题

java - Spring Boot 应用程序无法在 AWS 上运行

amazon-web-services - EC2从用户数据调用CLI

oracle11g - Docker容器中的Oracle11g数据库长时间启动

docker - 在容器中运行 Jenkins Job

javascript - 关于 JSON 对象

json - Postgres 多对多 JSON 聚合

java - 如何记录到显式 AWS CloudWatch 日志流并以编程方式更改它 (Java/Scala/log4j)