This question feels too obvious to not already have an answer but all of my google searches are coming up with nothing.

In docker (docker-compose) you can easily get the IP of another container by hostname. If you have explicitly created and assigned a network this just works out of the box. So a container foo can connect to another container bar simply by looking up the hostname "bar".

I'm trying to achieve something similar in AWS ECS to allow a container from one service to talk to a container in another service. The ECS cluster has multiple hosts so I don't think I can just specify bridge type networking.

Note that the protocol I need this for is not HTTP so an application load balancer is already out of the question.

Is there a recommended way to let one container discover another on the same cluster via hostname?


Amazon ECS service discovery is integrated in ECS:

This makes it possible for an ECS service to automatically register itself with a predictable and friendly DNS name in Amazon Route 53. As your services scale up or down in response to load or container health, the Route 53 hosted zone is kept up to date, allowing other services to lookup where they need to make connections based on the state of each service.

The linked blog post contains in deep explanation and sample code.

  • Thanks for the reference. Though link only answers are generally discouraged. As it happens this is far from an "In depth explanation", it's actually very high level. And it has no example code besides a "hello world" python flask app ... which is irrelevant to the question. – Philip Couling Nov 24 '20 at 15:25

Your Answer

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 or ask your own question.