Container Binding in AWAR Fargate

I am trying to set up a small example in AWG Fargate and try to create one application container with one database container.

The task definition starts both containers, but my application container does not work with getaddrinfo ENOTFOUND db db:3306. Thus, the database container cannot be found by my application container.

Since Fargate does not allow the "linking" of Docker containers, I would like to know how they can communicate with each other. The database container has a name dbwith a port 3306, and my application container is configured to use it.

Unfortunately, container reference definitions are not available for Fargate, but only for "oldschool" ECS / EC2.

In the local docker configuration, it works this way.

+11
source share
2 answers

Containers in Fargate tasks use a namespace on the network, so you don’t need to use links at all. You can just chat through localhost.

For example, if you have container A running a web server on port 8000, container B can reach it with curl http://localhost:8000/

+11
source

Perhaps you can configure it so that services can exchange information on a public IP address with each other, and then protect ports using VPC, only services can communicate with them.

0
source

Source: https://habr.com/ru/post/1692413/


All Articles