I have a working container in Amazon\'s ECS that runs a program as a task. I would like to pass some program arguments, as I would do when running locally with docker run<
1. If you normally pass in command line arguments to your script like
python myscript.py --debug --name "joe schmoe" --quality best --dimensions 1920 1080
2. And you have a docker image with an entrypoint to run that script like
FROM python:3.7-alpine
# Add the application folder to the container
COPY . /myscript
WORKDIR /myscript
# Install required packages
RUN pip install -r requirements.txt --upgrade
# Run the script when the container is invoked
ENTRYPOINT ["python", "myscript.py"]
3. Then when editing a task/container definition via the aws ecs user interface, you must place the arguments into the "Command" field under the "Environment" section of the container settings and replace all spaces between arguments and values with commas, like so:
--debug,--name,joe schmoe,--quality,best,--dimensions,1920,1080
Items with spaces like joe schmoe
are quoted as "joe schmoe", which is why something like --quality best
wouldn't work, and instead needs to be comma delimited as --quality,best
4. After creating the task, if you take a look at the container details in the task definition, the command is displayed as:
["--debug","--name","joe schmoe","--quality","best","--dimensions","1920","1080"]
which is the same syntax accepted by the CMD instruction in a Dockerfile.