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?
The default reserved ports are 22 for SSH, the Docker ports 2375 and 2376, and the Amazon ECS container agent ports 51678-51680.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With