Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS ECS Fargate and port mapping

I have two containers and they expose the same port. I want to run them in the same task as they are part of the same system. But I cannot do this with Fargate because there are no port mapping and the host port should be the same as container port for the awsvpc network mode (only supported by Fargate).

It's an essential feature of Docker and it's strange that it seems to be not supported by Fargate. Is there really no way to do this or I'm missing something?

like image 450
Anton Zherdev Avatar asked Jan 05 '18 22:01

Anton Zherdev


People also ask

What port does ECS use?

The default reserved ports are 22 for SSH, the Docker ports 2375 and 2376, and the Amazon ECS container agent ports 51678-51680.

What is dynamic port mapping ECS?

Well , Dynamic port mapping allows you to run multiple tasks over the same host using multiple random host ports (in spite of defined host port). Dynamic port mapping with an Application Load Balancer makes it easier to run multiple tasks on the same Amazon ECS service on an Amazon ECS cluster.

What is port mapping in container?

Port mapping is used to access the services running inside a Docker container. We open a host port to give us access to a corresponding open port inside the Docker container. Then all the requests that are made to the host port can be redirected into the Docker container.

Which AWS feature provides dynamic host port mapping?

However, an Application Load Balancer uses dynamic port mapping, so you can run multiple tasks from a single service on the same container instance. Note: Network Load Balancers can also be used for dynamic port mapping.


1 Answers

Use application load balancer to your service and set your custom port in target group and host port should be set the same as container port. This is our tested solution.

like image 160
Sunil Shakya Avatar answered Sep 25 '22 13:09

Sunil Shakya