CDK ECS Fargate - how to specify arguments to Docker container?

0

Hi, Trying to Deploy an ECS service running a single task with the image: datalust/seq:latest. I want to specify certain arguments to my container, how do I achieve the equivalent of running the following local command:

docker run --name seq -e ACCEPT_EULA=Y -p 5341:5341 -p 80:80 datalust/seq:latest

Using ECS Fargate. My CDK code is below:

      image: ContainerImage.fromRegistry('datalust/seq:latest'),
      containerName: `SeqContainer`,
      command: [`--name`, `seq`,`-v`, `/efs:/efs`],
      essential: true,
      cpu: 1024,

      environment: {
        ACCEPT_EULA: 'Y'
      },
      portMappings: [
        { containerPort: 80, hostPort: 80 },
        { containerPort: 5341, hostPort: 5341 }
      ],
      logging: new AwsLogDriver({
        logGroup: new LogGroup(this, 'SeqLogGroup', {
          logGroupName: '/aws/ecs/SeqLogGroup',
          removalPolicy: RemovalPolicy.DESTROY
        }),
        streamPrefix: 'SeqService'
      })
    })

However when I run with this config, it fails to start my task properly, it seems that the Command specification overrides the default behaviour of the container, whereas I just want to supply arguments to the container as an addition to the default behaviour.

Manav
feita há 2 anos2560 visualizações
1 Resposta
1

The command parameter of the task definition is to specify the command to run in your container at startup. The other parameters that you send to the docker cli (i.e. -e, -v, -p) usually map to other parameters of the task definition.

You properly used environment for -e and portMappings for -p. For -v you need to use volumes and mountPoints in your Task Definition. You don't need the --name parameter, it is specified in containerName.

See this link for more information on how to use EFS volumes with ECS: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html

See this for full reference of task definition parameters: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html

profile pictureAWS
respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas