4

I have 2 ECS Services running with EC2 launch type and bridge networking mode. each service is having 1 task and both tasks are running on same EC2 container host.

on the Same ECS host, API container in 1st task is trying to communicate DB container in 2nd task by host name and port number( ex: http://abc-def:5000). what are the ways to achieve this ?

Shah
  • 67
  • 4

1 Answers1

2

Your options are:

  1. Put everything in a single task definition. Then you can use the link attribute to enable container A to communicate with container B like so B:port. Notice that link does not support circular relations meaning if A can talk with B, B will not be able to do that as well.

  2. Switch to network mode host. This way you can communicate with localhost.

  3. Proper service discovery with a tool like Consul or AWS ECS Service Discovery. I have no experience with the latter. See here.

  4. Put your tasks behind ALB and use this load balancer to communicate between tasks.

trallnag
  • 2,041
  • 1
  • 17
  • 33