Amazon-web-services – Amazon Elastic Beanstalk vs EC2 instance with docker containers

amazon ec2amazon-elastic-beanstalkamazon-web-servicesdocker

If I understand correctly, Elastic Beanstalk creates an EC2 instance for each application you deploy. However, an application typically doesn't run at 100% CPU, yet amazon charges you per instance used. So if I deployed 5 apps with Dockerfiles, AWS would charge the usage of 5 EC2 instances per month.

With this in mind, can't I just simply launch an EC2, install docker and run my containers in there? Wouldn't that be much more cost-effective?

Best Answer

AWS has integrated Elastic Beanstalk (EB) with the EC2 Container Service (ECS) to support multi-container Docker environments. An EB environment composed of multiple instances in an autoscaling group can run multiple containers per instance, managed through the ECS agent and its API. Use .ebextensions to map multiple ELB listeners to the containers running on EC2 instances.

See this tutorial for running an Nginx + PHP-FPM in separate containers.

Thanks @Synturas for tipping me off to this update.