Search code examples
amazon-ecsaws-fargate

How can I do to not let the container restart in aws ecs?


I have built an container and run successfully by aws ecs fargate. The container will download file form s3, process and upload file to s3. But because the ecs service restart policy, the service will restart a container which I don't want.

In Kubernetes, I use restartPolicy: OnFailure, but I have read the doc for ecs, all the task definition and service definition. The closest parameter I find is "dockerLabels", set the set "--restart": 'no', but it didn't work.

How can I do to not let the container restart in ecs?


Solution

  • What you are describing aligns with the use case for running ECS tasks manually or according to a schedule. Unlike running tasks with the service scheduler, the tasks won't be restarted and are ideal for one-time or periodic batch execution workloads. You can run a task manually from the AWS Console or using the RunTask API. Tasks can be used to mimic Jobs and CronJobs in Kubernetes.

    Services will always maintain the desired number of tasks and this behavior can't be modified:

    If any of your tasks should fail or stop for any reason, the Amazon ECS service scheduler launches another instance of your task definition to replace it and maintain the desired count of tasks in the service depending on the scheduling strategy used.