Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker : compose file is incompatible with Amazon ECS

I am trying to deploy my docker image in AWS ECS. I have created the ECR repository and done all required steps till pushing the image to ECS.

My docker-compose.yaml looks like this

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

I am trying to run the command:

docker ecs compose  -n abc up 

And i get the following error:

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

I am using the latest version of docker i.e 19.03.08 and the latest aws-cli/2.0.39.

like image 483
Rajesh Puthsakayala Avatar asked Oct 15 '22 01:10

Rajesh Puthsakayala


1 Answers

I am facing the same trouble and I was able to accomplish it by removing all attributes in docker-compose.yaml except for image.

In your djangoapp service under the image attribute, you set the value to a URI with the comment "the uri after pushing the image". Presumably this is the URI to a locally-built docker image of djangoapp, which was pushed to a ECR repository.

Since you already built and pushed the djangoapp image to ECR, just leave the image attribute and comment out all other attributes listed in the error message from docker-compose.yaml:

  1. build
  2. volumes
  3. ...

In my case it helped.

The list of supported attributes: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-parameters.html

like image 53
Maksym Bielushkin Avatar answered Oct 21 '22 02:10

Maksym Bielushkin