如何将docker-compose.yml转换为Django的Dockerrun.aws.json

用户3667089:

我正在按照https://docs.docker.com/compose/django/的说明进行操作,以获取基本的dockerized django应用程序。我可以在本地运行它,而不会出现问题,但是我无法使用Elastic Beanstalk将其部署到AWS。这里阅读之后,我发现我需要将docker-compose.yml转换为Dockerrun.aws.json才能正常工作。

原始的docker-compose.yml是

version: '2'
services:
  db:
    image: postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

这是到目前为止我翻译的

{
  "AWSEBDockerrunVersion": 2,
  "volumes": [
    {
      "name": "db"
    },
    {
      "name": "web"
    }
  ],
  "containerDefinitions": [
    {
      "name": "db",
      "image": "postgres",
      "essential": true,
      "memory": 256,
      "mountPoints": [
        {
          "sourceVolume": "db"
          "containerPath": "/var/app/current/db"
        }
      ]
    },
    {
      "name": "web",
      "image": "web",
      "essential": true,
      "memory": 256,
      "mountPoints": [
        {
          "sourceVolume": "web"
          "containerPath": "/var/app/current/web"
        }
      ],
      "portMappings": [
       {
         "hostPort": 8000,
         "containerPort": 8000
       }
     ],
     "links": [
        "db"
      ],
      "command": "python manage.py runserver 0.0.0.0:8000"
    }
  ]
}

但它不起作用。我究竟做错了什么?

山姆·H:

我正在努力获取Dockerrun格式的详细信息。退房集装箱变换:“泊坞窗变换,撰写,ECS和马拉松配置” ......这是一个生命的救星。这是您的示例输出的内容:

{
    "containerDefinitions": [
        {
            "essential": true,
            "image": "postgres",
            "name": "db"
        },
        {
            "command": [
                "python",
                "manage.py",
                "runserver",
                "0.0.0.0:8000"
            ],
            "essential": true,
            "mountPoints": [
                {
                    "containerPath": "/code",
                    "sourceVolume": "_"
                }
            ],
            "name": "web",
            "portMappings": [
                {
                    "containerPort": 8000,
                    "hostPort": 8000
                }
            ]
        }
    ],
    "family": "",
    "volumes": [
        {
            "host": {
                "sourcePath": "."
            },
            "name": "_"
        }
    ]
}
Container web is missing required parameter "image".
Container web is missing required parameter "memory".
Container db is missing required parameter "memory".

也就是说,在这种新格式下,您必须告诉它分配每个容器多少内存。另外,您需要提供图像-没有构建选项。如评论中所述,您想要构建并推送到DockerHub或ECR,然后为其指定位置:例如,[org name]/[repo]:latest在Dockerhub上,或ECR的URL。container-transform确实在mountPointsvolumes你-这是惊人的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章