Search code examples
amazon-web-servicesdnshostnameaws-fargate

fargate hostname set awsvpc


I'm pushing out a Aws Fagate task with 2 containers.

One of the containers is Nginx, which is going to route the traffic to the other container running in the task.

In Docker Compose, the containers seem to route to each other using the Docker dns service.

This does not work in Fargate.

I'm sure someone else has figured out how to communicate between containers in Fargate. I see there is a Network Mode, but Fargate seeems to default to awsvpc, so the settings for the container do net allow me to set the hostname.

Does anyone have some ideas how to make it possible for two containers in the same task to be able to refer to each other by hostname ?


Solution

  • Since you are using awsvpc networking mode, containes which are part of same task, as in your case, can simply use localhost to communicate with each other:

    containers that belong to the same task can communicate over the localhost interface.

    So you could modify your application/containers to use localhost for between-container communication as part of the same task.