简体   繁体   English

如何将新容器追加到AWS ECS中正在运行的任务?

[英]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. 我正在使用AWS ECS启动容器以运行自动化测试,并且它们的数量无法事先知道,因为它们是由不同的事件触发的。

For some config reasons I have to start these tasks in EC2 mode only (not FARGATE ), 由于某些配置原因,我只能在EC2模式下启动这些任务(不是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: 我正在使用boto3来启动新的任务和容器,我与你分享这部分代码来做到这一点:

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 ? 所以我的问题是:有什么办法可以将新容器添加到正在运行的任务中?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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