You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWSEBDockerrunVersion已存在但ElasticBeanstalk部署提示缺失求助

解决ElasticBeanstalk部署时的AWSEBDockerrunVersion缺失错误

核心问题:Dockerrun.aws.json键名大小写错误

你的Dockerrun.aws.json中版本字段的键名写成了AWSEBDockerrunversion(末尾v小写),但ElasticBeanstalk要求的正确键名是**AWSEBDockerrunVersion**(末尾V大写)。大小写不匹配会直接导致EB无法识别版本字段,触发"AWSEBDockerrunVersion is missing"错误。

修正后的Dockerrun.aws.json:

{
    "AWSEBDockerrunVersion": 2,
    "containerDefinitions": [
        {
            "name": "client",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-client-prod",
            "hostname": "client",
            "essential": true,
            "memory": 1024,
            "portMappings": [
                {
                    "hostPort": 80,
                    "containerPort": 80
                }
            ]
        },
        {
            "name": "server",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-server-prod",
            "hostname": "server",
            "essential": true,
            "memory": 512,
            "portMappings":[
                {
                    "hostPort": 4000,
                    "containerPort": 4000
                }
            ]
        }
    ]
}

额外排查优化点

  • 确认构建工件完整性
    检查CodePipeline构建阶段输出的BuildArtifact是否包含Dockerrun.aws.json:可以查看CodeBuild日志的artifacts阶段输出,或直接访问S3存储桶中的构建压缩包,确保文件未遗漏、路径正确。

  • 补充环境变量替换步骤
    你的Dockerrun.aws.json使用了${AWS_ACCOUNT_ID}和${AWS_DEFAULT_REGION}变量,但CodeBuild不会自动替换JSON文件中的环境变量。需要在buildspec.yml的post_build阶段添加替换命令:

    post_build:
      commands:
        - echo Build complete on `date`
        - echo Pushing the Docker image
        - docker-compose --file=docker-compose.aws.production.yml push
        # 新增变量替换命令
        - sed -i "s/\${AWS_ACCOUNT_ID}/${AWS_ACCOUNT_ID}/g" Dockerrun.aws.json
        - sed -i "s/\${AWS_DEFAULT_REGION}/${AWS_DEFAULT_REGION}/g" Dockerrun.aws.json
    

    未替换变量会导致EB无法解析镜像地址,可能间接引发验证错误。

  • 确认平台版本兼容性
    你使用的ECS running on 64bit Amazon Linux 2/3.2.9平台完全支持AWSEBDockerrunVersion: 2,无需切换其他Docker分支,保持当前平台配置即可。

内容的提问来源于stack exchange,提问作者Afoolwhorippedhispants

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 12:53:18