TECHIES WORLD

For Techs.... Techniques.... Technologies....

AWS

How to run multiple ECS tasks in the same EC2 instance

ECS doesn't allow to run multiple tasks with same port on the same instance. But its possible to run multiple tasks with same port on the same instance using Dynamic port mapping.

This article explains the steps to configure Dynamic port mapping in ECS.

Step1: Login to AWS console.

Step2: Open EC2 console.

Step3: Create an Application Load Balancer and a target group. No need to register any targets to this target group.

Step4: Open the Amazon ECS console.

Step5: Set the host port to 0 for the task definition that is going to be created or updated. Make sure to set the container port mappings for the application also.

Step6: Create a new service using this task definition. Please note to assign the target group that created earlier.

That's all…