compose different environments
docker-compose expose the -f switch to load one or more docker-compose override files. Is there something similar for ecs-cli?
It seems to me that #129 is a duplicate of this. It would be really great to make ecs-cli support multiple -f.
In the meantime, there is a workaround : docker-compose has a validation command that shows the yaml files' concatenation in the console :
docker-compose -f docker-compose.file1.yml -f docker-compose.file2.yml config will output the concatenation of docker-compose.file1.yml and docker-compose.file2.yml.
Hi, I have just started using AWS for running docker and this is the first issue i encountered, is there any update on this? The workaround suggested by @floostmodern is good and can be put in a bash script to capture the output to a new file and execute the ecs-cli command with that file, but it would be better if the workaround was not required. Thanks
While it is true that docker-compose -f docker-compose.file1.yml -f docker-compose.file2.yml config will output the merged config for all the given override files, the resulting file:
- is not valid YAML
- is not valid docker-compose format
- is not consumable by ecs-cli
- requires additional touch-ups before it can be successfully to
ecs-cli
I don't really see this as a valid work-around for this. If this feature is not to be supported, it would be helpful to show an error when ecs-cli is run with this type of syntax (today this is allowed, seems to work but silently fails):
ecs-cli compose -f docker-compose.yml -f docker-compose.override-aws.yml -p MyProject create
We require this functionality as well to set a few environment/stage/cluster specific options for our containers. While we could potentially configure them with environment variables as well, it is much more inline with our development workflow to merge and overwrite them using different files.
We normally run services like this:
$ docker-compose -f service.yml -f stage.yml up/run
While the workaround by @floostmodern works for now, it would be great if ecs-cli supported this functionality natively. Especially since, as @PeterRJones mentioned, the output cannot be used directly and needs to be cleaned up first.
Building on what @floostmodern said, this works for me temporarily.
Full Command:
docker-compose -f docker-compose.yml -f docker-compose.production.yml config | sed "s/version: '2.0'/version: 2/" | ecs-cli compose --verbose --file /dev/stdin create
I tend to shorten it like so:
alias docker-compose-prod='docker-compose -f docker-compose.yml -f docker-compose.production.yml'
alias docker-compose-prod-config="docker-compose-prod config | sed \"s/version: '2.0'/version: 2/\""
alias ecs-cli-compose="docker-compose-prod-config | ecs-cli compose --file /dev/stdin --project-name $(basename $(pwd))"
Usage:
Just replace "ecs-cli compose" with "ecs-cli-compose".
ecs-cli help
ecs-cli-compose help
ecs-cli-compose create
ecs-cli-compose ps
You can now run ecs-cli compose up with multiple compose files with the latest commit. This will be included in the next release.
@yinshiua Great! When is the next release is scheduled?
Looks like it was included in the following release (according to the release notes): https://github.com/aws/amazon-ecs-cli/releases/tag/v0.6.1
I am still having this issue in v0.6.5... Is there any update on this? Was this feature removed after v0.6.1?
this doesnt work for me with latest client: ecs-cli compose --file docker-compose.yml --file docker-compose-aws.yml service up
so how to define multiple files? the overridden settings in my second file wont get picked up.
@logemann Are you sure you are using the latest ecs-cli? The above example does work for me. If you run with —debug what task definition does it spit out?
cant see a debug parameter. Tried several ways without luck. My ecs-cli version is 1.8