Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

amazon web services - 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.

question from:https://stackoverflow.com/questions/47637588/linking-container-in-aws-fargate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...