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?
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).
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 toname: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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With