【问题标题】:Docker Compose env_file in Multicontainer Elastic BeanstalkDocker 在多容器 Elastic Beanstalk 中编写 env_file
【发布时间】:2017-07-04 10:13:24
【问题描述】:

我有以下 docker compose 文件:

version: '2'

services:
  app:
    build: .
    command: >
      bash -cex "
        export LC_ALL=C.UTF-8
        export LANG=C.UTF-8
        /virtualenv/bin/flask run -h 0.0.0.0 -p 5050
      "
    env_file: env
    links:
    - postgres
    ports:
    - 8080:8080

如您所见,我正在使用 env_file 选项从文件 env 加载我的环境变量。

现在我正在尝试将此容器部署到 Elastic Beanstalk。 到目前为止,这是我的文件 Dockerrun.aws.json:

{
  "AWSEBDockerrunVersion": 2,

  "containerDefinitions": [

    {
      "name": "app",
      "image": "myorg/myimage",
      "essential": true,
      "memory": 256,
      "command": [
        "/bin/bash",
        "export LC_ALL=C.UTF-8",
        "export LANG=C.UTF-8",
        "/virtualenv/bin/flask run -h 0.0.0.0 -p 5050"
      ],
      "portMappings": [
        {
          "hostPort": 8080,
          "containerPort": 8080
        }
      ],
      "links": [
        "postgres",
      ]
    }

在 AWS Elastic Beanstalk documentation 中仅提及 environment 选项以传递一组 env 变量,但我找不到如何传递文件而不是变量数组。

有人知道如何将这个 docker-compose 文件正确翻译成 Dockerrun.aws.json 文件吗?

问候。

【问题讨论】:

    标签: amazon-web-services docker amazon-elastic-beanstalk docker-compose


    【解决方案1】:

    试试container-transform

    $ pip install container-transform
    $ cat docker-compose.yml | container-transform  -v
    

    它会将 ECS 格式打印到 STDOUT。

    【讨论】:

      猜你喜欢
      • 2017-07-26
      • 2018-06-20
      • 2017-10-14
      • 2017-12-26
      • 2017-05-07
      • 2021-11-25
      • 1970-01-01
      • 2018-12-05
      • 1970-01-01
      相关资源
      最近更新 更多