Hi,
I have an ECS task which has three containers A B and C.
In the task definition when defining container B, I have linked A. I gave A container link name as A only.
I have defined hostname of A B and C as A B and C
The task run on single EC2 instance machine.
While running from the docker container B I am able to ping A with the FQDN but from the container A I am not able to ping B.
Also, I am not able to link A container with B as it states as the loop.
This works well in docker compose on my local machine and only in ECS it fails.
I searched and found this could happen where there are multiple EC2 machine but not on one EC2 machine. My case I have only one EC2 machine.
Is there any simple workaround for this?
Note: Service discovery seems to be a complex, suggest some simple workaround if not give easy steps for creating a service discovery for this one ECS task.
Also, I am planning to use AWS Fargate so host file copying solution won't work for me.
@anasokan This seems like the same issue as #1166. As the Docker link option doesn't support bidirectional communication, you can try to use the awsvpc network mode, where all containers will be in the same network namespace so they can directly talk to each other.
Also, I am planning to use AWS Fargate so host file copying solution won't work for me.
In Fargate the task is launched with awsvpc mode, all the containers in the same task can directly talk to each other using localhost without the link option required.
Please let us know if the awsvpc mode solves your problem.
Thanks,
Peng
Closing issue for now since we haven't heard back in a while. Please reopen if needed. Thanks.
Most helpful comment
@anasokan This seems like the same issue as #1166. As the Docker
linkoption doesn't support bidirectional communication, you can try to use theawsvpcnetwork mode, where all containers will be in the same network namespace so they can directly talk to each other.In Fargate the task is launched with
awsvpcmode, all the containers in the same task can directly talk to each other usinglocalhostwithout thelinkoption required.Please let us know if the
awsvpcmode solves your problem.Thanks,
Peng