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

`ecs-cli local create` should docker-compose escape the env vars in entrypoint

Open remidebette opened this issue 4 years ago • 0 comments

Summary

Docker-compose files generated from a task definition with ecs-cli local create should escape the environment variables present in its entrypoint. Otherwise, the behavior on AWS ECS is not replicated on local with ecs-cli local up out of the box.

Description

Environment variables present in a Docker-compose entrypoint are not taken into account. As explained here: https://stackoverflow.com/questions/48184700/docker-variable-expansion-in-compose-entrypoint

If you have from the AWS Task definition the following docker-compose generated:

services:
  training:
    entrypoint:
    - /bin/sh
    - -c
    - echo $CONFIG

It will not work out of the box, even though the Task definition is perfectly fine. Therefore a manual change is necessary:

services:
  training:
    entrypoint:
    - /bin/sh
    - -c
    - echo $$CONFIG

Expected Behavior

Escape the $ tp $$ on the fly at the time of the docker-compose file creation or at the very least put a readable warning to the user if $ is detected prompting him to change the file.

Observed Behavior

With unchanged entrypoint and no warning the subsequent ecs-cli local up will start with the following docker-compose obscure warning:

$ ecs-cli local up                                                                                                            <aws:profile>
INFO[0000] The network ecs-local-network already exists 
INFO[0000] The amazon-ecs-local-container-endpoints container already exists with ID 4d0811b42103e46abf1cc24ab068d14558855e7b4c931b749040f1dc22e467b2 
INFO[0000] Started container with ID 4d0811b42103e46abf1cc24ab068d14558855e7b4c931b749040f1dc22e467b2 
INFO[0001] Using docker-compose.ecs-local.yml, docker-compose.ecs-local.override.yml files to start containers 
WARN[0000] The "CONFIG" variable is not set. Defaulting to a blank string. 

and the container will not behave as expected.

remidebette avatar Jan 21 '22 18:01 remidebette