简体   繁体   中英

how to append a new container to a running task in AWS ECS?

I'm using AWS ECS to start containers to run automated tests and their number cannot be known beforehand, because they are triggered by different events.

For some config reasons I have to start these tasks in EC2 mode only (not FARGATE ),

The issue is: I need to add new containers to a running task, but I couldn't achieve that, the only way I found is to start a new task for each new container, but this solution is very expensive in some cases.

I'm using boto3 to start the new tasks&containers, I share with you this part of code to do that:

client = boto3.client('ecs', region_name="eu-west-1")

networkConfiguration = {
            'awsvpcConfiguration': {
                'subnets': ['subnet-01', 'subnet-06'],
            }
        }

resp = client.run_task(
        cluster='run-on-demand',
        launchType='EC2',
        taskDefinition="task-01-ec2",
        networkConfiguration=networkConfiguration,
        overrides={
            'containerOverrides': [
                {
                    'name': "task-01-c1-ec2",
                    'environment': env_vars,
                    'cpu': 512,
                    'memory': 2048
                }
            ],
        },
        startedBy="admin",
        count=1
    )

so my question is: is there any way to add new container to a running task ?

简短回答: 这是不可能的 ,因为容器只在任务创建时定义。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM