Search code examples
amazon-web-servicescontainersamazon-ecsaws-fargate

Is it possible to have an AWS Fargate task that doesn't terminate when one of it's container exits?


I have a AWS Fargate task with two containers each running it's own part of a batch job. However, when one of the containers complete and exit, the whole task is killed by ECS. Is it possible to let the task run until both containers exit?

Though it may be anti-pattern, the containers can run independently of each other. They just use very little memory, but are long-running (~1hr) because of dependence on external API calls, so I was hoping to cram more than one in a 512Mb Task because I can't make a task use any less memory. So this is totally driven from a cost-saving perspective and not from any technical requirement. If I have to break out these out into separate tasks, that's acceptable, but I wanted to make sure there wasn't another way before I went that route.


Solution

  • Amazon ECS will terminate the task if any of the containers marked essential exit. You can have a task definition with multiple containers where some are not marked essential, but at least one container in every task must be marked essential. See the documentation for more information.