Is it possible to run multiple docker containers in one EC2 instance through AWS ECS (EC2 Container Service)?
5 Answers
Yes.
AWS's documentation/product details doesn't ever come out and say it explictly, but it talks about launching many containers to a cluster. A cluster can be one instance.
When configuring a container, you specify memory and CPU usage. ECS uses that to "schedule" (or "pack") an EC2 with Docker containers.
All containers defined in one ecs task are deployed onto the same instance.
Even if the cluster has many instances all containers defined in one task are located on the same ec2 instance. The containers can access each other using the links defined between them.
This is equivalent to a POD in Kubernetes.
Exactly. That's possible.
Write one task definition per docker image and run that through a service to automate the deployment. You also need to be careful while dividing the memory and CPU among different tasks to run different docker.
Here is the link for reference.
It can be achieved using task definition. If you are familiar with kubernetes,task definition is more like a pod in k8s.
Task definition -> Create new revision or create new task definition.
Go to Container section and add all the container you want to run in the task. Define container name and the image URL.
Note: Allocate memory/cpu required for each container.
Now when you save and run the task in any EC2/Fargate resource, all the containers defined in the task definition runs together.

