In Kubernetes cluster pods can easily communicate using its dns names or ip. Like this how can I know dns name of any container and communicate between two containers between 2 different EC2 machines.
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
In Kubernetes, cluster pods use kube-dns to connect between them.
So in ECS, it has its service discovery itself. Or if you want to connect tasks in the same cluster, you can use their names to connect.
An example is here
For other people that come here, if your containers are in the same cluster but in different services a good choice can be aws Ecs Service Connect
Try to make your implementation by aws cli or by cloudformation. At least until today(20.03.2023) I found the info for implementation via the aws console confusing.
So if you decide by console pay attention to the task definition json and check the following fields, in your Task Definition, have been properly configured:
And pay attention to the network mode documentation explaining that the default value is bridge but you need to specify:
The rest of explanation is quite well explained and keep in mind with network mode bridge you can control and to see containers at docker level but with is awsvpc you need to create security groups for containers and save DNS records pointed on AWS Cloud Map and I think this can be another scenario