Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking Container in AWS Fargate

I try to setup a little example on AWS Fargate and try to have one application container with one database container there.

The task definition starts both containers, but my app container fails with getaddrinfo ENOTFOUND db db:3306. Therefore, the database container could not be found by my app container.

Since Fargate does not allow "links" of Docker containers, i'd like to know how they can communicate with each other. The database container has the name db with port 3306 and my app container is configured to use this.

Unfortunately, defining links of containers is not available for Fargate, but only for "oldschool" ECS/EC2.

In a local docker-compose setup it is working this way.

like image 910
sebastian Avatar asked Dec 04 '17 16:12

sebastian


People also ask

Can you SSH into fargate container?

I can confirm, yes you can SSH into a Fargate container by running sshd and properly configuring the security group.

Can I Exec into a fargate container?

NEW – Using Amazon ECS Exec to access your containers on AWS Fargate and Amazon EC2. Today, we are announcing the ability for all Amazon ECS users including developers and operators to “exec” into a container running inside a task deployed on either Amazon EC2 or AWS Fargate.

Can you SSH into ECS container?

Amazon ECS container instances have no password, and you use a key pair to log in using SSH.


2 Answers

Containers in Fargate tasks share a network namespace, so you don't need to use links at all. You can simply communicate via localhost.

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

like image 179
Noah Avatar answered Oct 05 '22 06:10

Noah


Now you can use AWS Cloud Map service discovery integration with Amazon ECS https://docs.aws.amazon.com/AmazonECS/latest/bestpracticesguide/networking-connecting-services.html With this service you will be able to call other container via DNS name

like image 31
Dr.Crazy Avatar answered Oct 05 '22 06:10

Dr.Crazy