volume and ecs-params : "cannot unmarshal !!map into []utils.DockerVolume"
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"
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 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.
It's ok, don't worry :) hard to find ! I hope you can correct the documentation 👍
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 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 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?