Task networking with the bridge network mode

Amazon ECS tasks that use the bridge network mode use Docker's built-in virtual network, which runs inside each container. The bridge is an internal network namespace that allows each container that's connected to the same bridge network to communicate with each other. It also provides an isolation boundary from containers that aren't connected to the same bridge network.

With the bridge network mode, you use static or dynamic port mappings to map ports in the container with ports on the Amazon EC2 host. For more information, see Choosing a network mode in the Amazon ECS Best Practices Guide .

Warning

To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.

  • Stack Overflow Public questions & answers
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Talent Build your employer brand
  • Advertising Reach developers & technologists worldwide
  • About the company

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Health check on container port and host port in ECS + ALB

I have a problem with my deployment in ECS.

I try to deploy 4 instances of 2 docker images on 2 EC2 instances with an ALB in front.

So in my tasks definitions, I use the dynamic port mapping (2 Nginx on container port 80).

This creates a trouble in the Health check of my target group. In fact, for each instance, I have a health check on the dynamics port (that is ok) and on the container port (80).

enter image description here

So can you help me ton find why I have that type of error (this error make my server terminated each 5 minutes....)

Thanks in advance for your help :D

David's user avatar

2 Answers 2

So to me it looks like you aren't completely using dynamic port mapping. For dynamic port mapping you have

Client -> ALB (port 80) -> EC2 host (dynamic port) -> container (dynamic port) -> nginx (port 80)

None of your healthchecks should be hitting port 80 since the only thing that uses port 80 is external connection into your application and nginx (but it is mapped to a different port). For ALB healthchecks all you really need is a path to hit and the port will default to the port that it connects on.

See the host port mapping in this doc: http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html

ALB Health Check Docs: http://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html

davis190's user avatar

I found the solution with the AWS support.

So there are two problems here:

To disable the health which kill the EC2 instance, go to the auto scaling group and switch health check to "EC2" type

To remove the health check on port 80, go to the auto scaling group, and under "Target groups" section, removes the target groups managed by ECS

Your Answer

Sign up or log in, post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged amazon-web-services amazon-ec2 amazon-ecs health-monitoring elastic-load-balancer or ask your own question .

Hot Network Questions

port mapping ecs host

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

IMAGES

  1. ECS

    port mapping ecs host

  2. Managed Switch Port Mapping Tool 2.53 Free download

    port mapping ecs host

  3. Understanding Dynamic Port Mapping in Amazon ECS with Application Load Balancer!

    port mapping ecs host

  4. 6_Port_Mapping

    port mapping ecs host

  5. Dynamic Port Mapping in ECS with Application Load Balancer

    port mapping ecs host

  6. Understanding Dynamic Port Mapping in Amazon ECS with Application Load Balancer!

    port mapping ecs host

VIDEO

  1. 0226 SmBus21st-WZU Getting to the Nuts and Bolts

  2. Meet Dr. Teresa Hairston

  3. Faithvera weds Joseph Sila

  4. LIVE CAMERA NEST STREAM.PORT LINCOLN OSPREY.2022.11.21

  5. Début des travaux de la caserne des pompiers

  6. MEGAN Horror Movie Dance Party #shorts

COMMENTS

  1. PortMapping

    Port mappings allow containers to access ports on the host container instance to send or receive traffic. Port mappings are specified as part of the container definition. If you use containers in a task with the awsvpc or host network mode, specify the exposed ports using containerPort.

  2. Set up dynamic port mapping for Amazon ECS

    Open the Amazon ECS console, and then set the host port to 0 for the task definition that you're creating or updating. Be sure to set the container port mappings for your application. Important: The host and awsvpc network modes do not support dynamic host port mapping.

  3. Task networking with the bridge network mode

    It also provides an isolation boundary from containers that aren't connected to the same bridge network. With the bridge network mode, you use static or dynamic port mappings to map ports in the container with ports on the Amazon EC2 host. For more information, see Choosing a network mode in the Amazon ECS Best Practices Guide.

  4. amazon web services

    ECS uses 4 networking modes. awsvpc, bridge, host and none. None is not relevant here as there is no networking there. For awsvpc, the container gets its own ENI. Which means that your container will act as a host and the port that you expose will be the port that you serve on.

  5. Health check on container port and host port in ECS + ALB

    For dynamic port mapping you have Client -> ALB (port 80) -> EC2 host (dynamic port) -> container (dynamic port) -> nginx (port 80) None of your healthchecks should be hitting port 80 since the only thing that uses port 80 is external connection into your application and nginx (but it is mapped to a different port).