容器转换给出缺少图像参数错误

Container transform gives missing image parameter error

当我尝试使用 container transform 转换 Docker 撰写文件时,出现以下错误:

Container "container-name" is missing required parameter 'image'.

带图片参数的服务,运行正常。但是,带有构建参数而不是图像的参数会导致错误。我想通过使用构建参数基于 Docker 文件构建一些图像,而我根本不需要 Docker 撰写文件中的图像参数。这里最有效的解决方案是什么?

这是一个例子:

成功转换 db 服务:

Docker-compose.yml:

db:
 image: postgres

Dockerrun.aws.json:

 "containerDefinitions": [
        {
            "essential": true,
            "image": "postgres",
            "memory": 128,
            "mountPoints": [
                {
                    "containerPath": "/var/lib/postgresql/data/",
                    "sourceVolume": "Postgresql"
                }
            ],
            "name": "db"
        }

web 服务的未成功转换,因为使用 build 而不是 image 参数:

Docker-compose.yml:

web:
 build: 
  context: .
  dockerfile: Dockerfile

问题是 AWS ECS(=弹性容器服务)任务定义不能依赖 Docker 文件来构建映像。图像必须已经构建好才能在任务定义中使用。因此,"image" 键在任务定义 json 文件中是必需的,因此它必须在您要从中转换的 docker-compose 文件中。

任务定义的图像可以来自 Docker hub(就像 postgres 图像一样)或者您可以构建自己的图像并将它们推送到 AWS ECR(=弹性容器注册表) .