【问题标题】:Docker : compose file is incompatible with Amazon ECSDocker:撰写文件与 Amazon ECS 不兼容
【发布时间】:2020-12-02 17:06:51
【问题描述】:

我正在尝试在 AWS ECS 中部署我的 docker 映像。我已经创建了 ECR 存储库并完成了所有必需的步骤,直到将映像推送到 ECS。

我的 docker-compose.yaml 看起来像这样

version: '3'

services:

  djangoapp:
    image: xxxxx.dkr.ecr.ca-central-1.amazonaws.com/abc:latest #uri after pushing the image
    build: .
    volumes:
      - .:/opt/services/djangoapp/src
      - static_volume:/opt/services/djangoapp/static  # <-- bind the static volume
      - media_volume:/opt/services/djangoapp/media  # <-- bind the media volume
    networks:
      - nginx_network
      - database1_network
    depends_on:
      - database1

      
  nginx:
    image: nginx:1.13
    ports:
      - 80:5000
    volumes:
      - ./config/nginx/conf.d:/etc/nginx/conf.d
      - static_volume:/opt/services/djangoapp/static  # <-- bind the static volume
      - media_volume:/opt/services/djangoapp/media  # <-- bind the media volume
    depends_on:
      - djangoapp
    networks:
      - nginx_network

  database1:
    image: postgres:10
    env_file:
      - config/db/database1_env
    networks:
      - database1_network
    volumes:
      - database1_volume:/var/lib/postgresql/data

networks:
  nginx_network:
    driver: bridge
  database1_network:
    driver: bridge

volumes:
  database1_volume:
  static_volume:  # <-- declare the static volume
  media_volume:  # <-- declare the media volume

我正在尝试运行命令:

docker ecs compose  -n abc up 

我收到以下错误:

WARN[0000] services.build: unsupported attribute        
WARN[0000] services.volumes: unsupported attribute      
ERRO[0000] published port can't be set to a distinct value than container port: incompatible attribute 
WARN[0000] services.volumes: unsupported attribute      
WARN[0000] services.env_file: unsupported attribute     
WARN[0000] services.volumes: unsupported attribute      
WARN[0000] networks.driver: unsupported attribute       
WARN[0000] networks.driver: unsupported attribute       
compose file is incompatible with Amazon ECS

我正在使用最新版本的 docker,即 19.03.08 和最新的 aws-cli/2.0.39。

【问题讨论】:

  • 我将所有非 ECS 本地 Compose 设置移动到 docker-compose.override.yml,默认情况下在 docker-compose.yml 之后选择该设置。然后,当我部署到 ECS 时,我明确指定了单独文件 docker compose -f docker-compose.yml up。这样可以保持清洁。您还可以将仅 ECS 设置移动到 docker-compose.ecs.yml,并在部署到 ECS 时也指定它。

标签: django amazon-web-services docker docker-compose amazon-ecs


【解决方案1】:

我遇到了同样的麻烦,我可以通过删除docker-compose.yaml 中除image 之外的所有属性来解决此问题。

image 属性下的djangoapp 服务中,将值设置为带有注释“推送图像后的URI”的URI。大概这是一个本地构建的 docker 镜像djangoapp 的 URI,该镜像被推送到 ECR 存储库。

由于您已经构建并将 djangoapp 图像推送到 ECR,只需保留 image 属性并注释掉来自docker-compose.yaml 的错误消息中列出的所有其他属性:

  1. 构建
  2. ...

就我而言,它有所帮助。

支持的属性列表:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-parameters.html

【讨论】:

    【解决方案2】:

    Docker 决定不允许这样做。这就是他们在 Slack convo 上所说的:"We decided to not support this as this would only apply to ingress traffic, not service-to-service, which would be both confusing and inconsistent with local development"

    【讨论】:

      猜你喜欢
      • 2020-08-13
      • 1970-01-01
      • 2021-07-26
      • 2019-01-29
      • 2020-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多