amazon-ecs-cli icon indicating copy to clipboard operation
amazon-ecs-cli copied to clipboard

volume and ecs-params : "cannot unmarshal !!map into []utils.DockerVolume"

Open gmembre-zenika opened this issue 7 years ago • 6 comments

Summary

I'm trying to start a service with a persitant volume with docker-compose file and ecs-params. I can't get a task definition with a valid volume definition.

Could you please help ?

Description

I tried with ecs-cli v1.11.0, v1.12.1 on OS X without sucess.

Config files

  • docker-compose.yml
version: '3'
services:
  persist:
    image: XXXXXX.dkr.ecr.eu-west-3.amazonaws.com/service-persist:master
    ports:
      - "0:8080"
    volumes:
      - vpersist:/www
volumes:
  vpersist:
  • ecs-params.yml
version: 1
task_definition:
  services:
    persist:
      mem_limit: 40MB
      essential: true
  docker_volumes:
    name: vpersist
    scope: shared
    autoprovision: true
    driver: rexray/ebs
      driver_opts:
       volumetype: gp2
       size: 5

Observed Behavior

ecs-cli compose --verbose --file docker-compose.yml --cluster uat-api --project-name uat-persist-master service up --container-name persist --container-port 8080 --target-group-arn XXXXXX
DEBU[0000] Parsing the compose yaml...
DEBU[0000] Docker Compose version found: 3
DEBU[0000] Parsing v3 project...
DEBU[0000] Parsing the ecs-params yaml...
ERRO[0000] Unable to open ECS Compose Project            error="Error unmarshalling yaml data from ECS params file: ecs-params.yml: yaml: unmarshal errors:\n  line 8: cannot unmarshal !!map into []utils.DockerVolume"
FATA[0000] Unable to create and read ECS Compose Project  error="Error unmarshalling yaml data from ECS params file: ecs-params.yml: yaml: unmarshal errors:\n  line 8: cannot unmarshal !!map into []utils.DockerVolume"

gmembre-zenika avatar Jan 16 '19 22:01 gmembre-zenika

I found : a minus sign - is missing in front of name: vpersist. The complete file is :

version: 1
task_definition:
  services:
    persist:
      mem_limit: 40MB
      essential: true
  docker_volumes:
    name: vpersist
    scope: shared
    autoprovision: true
    driver: rexray/ebs
      driver_opts:
       volumetype: gp2
       size: 5

The documentation is lacking this information (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-ecsparams.html) : the minus is missing in the grammar and in the description

  docker_volumes:
      name: string
      scope: string
      autoprovision: 
      driver: string
      driver_opts: boolean
         string: string
      labels:
         string: string

It should tell that a list is expected

docker_volumes – This parameter allows you...

gmembre-zenika avatar Jan 17 '19 15:01 gmembre-zenika

@gmembre-zenika Apologies for this inaccuracy in our docs! We'll get that fixed. The - is supposed to be there since docker_volumes is a list of volumes.

PettitWesley avatar Jan 17 '19 19:01 PettitWesley

It's ok, don't worry :) hard to find ! I hope you can correct the documentation 👍

gmembre-zenika avatar Jan 17 '19 22:01 gmembre-zenika

Hello!! How can I define many volumes into docker_volumes?

ex: docker_volumes: - name: "jenkins_home" - name: "sonarqube_conf" - name: "sonarqube_data" - name: "sonarqube_logs" - name: "sonarqube_extensions" - name: "postgresql" - name: "postgresql_data"

lucaslimaimpulso avatar Feb 15 '19 18:02 lucaslimaimpulso

@lucaslimaimpulso That should work- name is the only required field. Make sure it's indented though:

docker_volumes:
  - name: "jenkins_home"
  - name: "sonarqube_conf"
  - name: "sonarqube_data"
  - name: "sonarqube_logs"
  - name: "sonarqube_extensions"
  - name: "postgresql"
  - name: "postgresql_data"

PettitWesley avatar Feb 15 '19 19:02 PettitWesley

@PettitWesley Thank you It's works. But the docker_volumes's right indented is:

version: 1
task_definition:
   services:
docker_volumes:

not inside if task_difinition as documentation https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-ecsparams.html:

version: 1
task_definition:
    services:
    docker_volumes:

And what I need to set up to use always the same volume when I run ecs-cli compose up?

lucaslimaimpulso avatar Feb 18 '19 12:02 lucaslimaimpulso