docker run program arguments in aws ecs

后端 未结 5 991
予麋鹿
予麋鹿 2021-02-07 04:59

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<

5条回答
  •  孤街浪徒
    2021-02-07 05:27

    When you run a task in ECS you can specify container overrides.

    In the AWS console this can be found at the bottom in the Advanced Options section.

    On the CLI you can pass in a JSON object with the overrides like so:

    aws ecs run-task ... --overrides '{"containerOverrides": [{"name": "whatever", "command": ["foo", "bar"}]}'
    

    The command is the CMD that gets executed inside the container.

    In the same way environment variables can be passed to a container. Here's the list of possible options as described in the aws-cli docs:

    {
      "containerOverrides": [
        {
          "name": "string",
          "command": ["string", ...],
          "environment": [
            {
              "name": "string",
              "value": "string"
            }
            ...
          ],
          "cpu": integer,
          "memory": integer,
          "memoryReservation": integer
        }
        ...
      ],
      "taskRoleArn": "string",
      "executionRoleArn": "string"
    }
    

    For some reason the name always has to be set in the overrides. ¯\_(ツ)_/¯

提交回复
热议问题