Running multiple ECS tasks based on same task definitions in one host, using different ports

血红的双手。 提交于 2019-12-22 10:56:59

问题


I have one ecs task definition. Can multiple tasks of the above task definition can run on one EC2 instance on several ports ?

I have already have running several tasks running on several ec2 instances. I want to reduce the consumption of resources. As one EC2 instance has more than enough resources to run several tasks. Is it possible to run same task several times on different ports on one EC2 instance ?


回答1:


Yes, ECS has very good support for this since 2016. You can leave the host port empty in the container definition, this will result in a random port to be chosen for your container. As a result, more instances of the same task definition can run on one ECS instance.

You can configure your ECS service in combination with an Application Load Balancer so that when it starts a new task, it will register the port number in the associated target group. This way you never have to deal with the random port.

If you setup your service via the AWS console, configuration is pretty straightforward.




回答2:


This can be configured by setting Host Port to be 0 in Port Mappings setting of Container Definitions while defining Task.

Following setting is available in Container Definition of Task.

It allows ECS to assign random ports to Tasks running in same EC2.

For more details please check - Setup Dynamic Port Mapping for ECS



来源:https://stackoverflow.com/questions/41221897/running-multiple-ecs-tasks-based-on-same-task-definitions-in-one-host-using-dif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!