Home > front end >  ECS multi container setup
ECS multi container setup

Time:11-25

I need help with the following scenario. I have three containers which need to run on ECS with alb in front. I have nginx-frontend, php, nginx-backend. Both nginx containers depend on the php container. I only want to expose the frontend container. How can I tie them together without added alb's in front of each?

I use terraform to configure all parts including (ALB,ECR, ECS, ...) I wanted to know how can I connect the containers without having each with an alb in front.

Localy I run them with docker-compose.

CodePudding user response:

This is a somewhat broad question but I'll try to give an answer that guides you in the right direction.

You can try using a infrastructure as code (IaC) to quickly get something working and workout what you need and what parts you don't need. You can look at what gets deployed to see how a functional ECS infrastructure is built, it will usually involve a VPC, NAT, Security groups, Internet Gateway, ALB, ECR and more parts. Seeing all those parts getting deployed and connected can further help you understand your needs.

Some examples of IaC running ECS: https://www.pulumi.com/docs/guides/crosswalk/aws/ecs/ https://registry.terraform.io/modules/cn-terraform/ecs-fargate/aws/latest

To answer your more specific question regarding the ALB you will only need to connect the frontend to the ALB with a target group.There is different ways of connecting your containers, service discovery is one way to create host names for each container in a private network. You can then just call your backend from your frontend similar to what you do with docker-compose.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html

CodePudding user response:

If you have a docker compose file possibly the easiest thing to do is to create an ECS context in docker and deploy your compose file with a docker compose up. You can read more here

  • Related