Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communication between containers in ECS task definition

I have a task definition in ECS running in awsvpc mode, containing 2 docker containers. My question is how can I communicate between containers in a task definition. Do they act similar to docker-compose?

like image 717
Edwin Avatar asked Oct 02 '19 07:10

Edwin


2 Answers

Multiple containers within a task in awsvpc networking mode will share the task ENI and the network namespace, so they can communicate to each other using localhost (or the equivalent 127.0.0.1 loopback IP address).

like image 79
Raoni Avatar answered Oct 21 '22 10:10

Raoni


The linking concept is only valid in case of AWS ec2 type service, you can not use linking in awsvpc network mode. linking between task is only allowed in that container which is part of the same task definition, it mean you should run two containers in the same task definition to create linking which similar to docker-compose.

links
Type: string array

Required: no

The link parameter allows containers to communicate with each other without the need for port mappings. Only supported if the network mode of a task definition is set to bridge. The name:internalName construct is analogous to name:alias in Docker links. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.

Note

This parameter is not supported for Windows containers or tasks using the awsvpc network mode.

container-linking-in-task-definition

You can use service discovery in case of AWS VPC a recommended approach by AWS incase of AWSvpc mood.

like image 27
Adiii Avatar answered Oct 21 '22 11:10

Adiii