Docker:撰写文件与Amazon ECS不兼容

问题描述

我正在尝试在AWS ECS中部署我的Docker映像。我创建了ecs仓库,并完成了所有必要步骤,直到将映像推送到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。

解决方法

Docker 决定不允许这样做。这是他们在 Slack 会议上说的:"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"

,

我也遇到了同样的麻烦,我能够通过删除除图像之外的所有属性来完成此任务。由于您已经构建了映像,因此只需将其保留并从docker中注释掉即可,并撰写错误消息中列出的所有其他属性:

  1. 构建
  2. 音量
  3. ...

对我而言,它有所帮助。

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