Three ways to run Docker on AWS

Andreas Wittig – 19 Mar 2019

There are a bunch of different ways to run your containerized workloads on AWS. This blog post compares the three most important ways to run Docker on AWS:

  • Amazon Elastic Container Service (ECS) with AWS Fargate
  • Amazon Elastic Container Service for Kubernetes (EKS)
  • AWS Elastic Beanstalk (EB) with Single Container Docker

Three ways to run Docker on AWS

The following table compares the three different approaches.

ECS + Fargate EKS EB
Complexity High Very High Low
Flexibility High Very High Medium
Operational effort Very Low Medium Medium
Maturity of AWS integrations Very High Medium High
Inter-service communication for microservices High High n/a
Cloud agnostic? No Yes No
Multiple applications per host? Yes Yes No

Below you will find more information about all three options.

ECS with Fargate

First, let’s have a look at ECS, a fully-managed container orchestration service. ECS is a proprietary but free of charge solution offered by AWS. It is important to mention that ECS provides a high level of integration with the AWS infrastructure. For example, containers are 1st class citizens of the VPC with their network interface (ENI) and security groups.

ECS offers service discovery via a load balancer or DNS (Cloud Map).

Aside from that ECS is the only option to run Docker containers without running EC2 instances on AWS. Fargate is the compute engine for ECS. All the heavy lifting of scaling the number of EC2 instances and containers, rolling out updates to EC2 instances without affecting containers, and many more is gone.

ECS is free of charge. Fargate is billed per second based on CPU and memory allocated for your containers. A container with 1 vCPU and 4 GB is about USD 30 per month.

Keep in mind the following limitations of Fargate:

  • General purpose compute capacity only. Fargate does not support GPU, CPU/memory optimized configurations at the moment.
  • Persistent volumes are not supported out of the box (e.g., Docker volume driver).
  • No discounts for reserved capacity available.

EKS (Kubernetes)

The 2nd option to run Docker containers on AWS is Kubernetes (K8s). In summary, K8s is an open-source container orchestration solution. AWS offers the K8s master layer as a service. The master layer is responsible for storing the state of the container cluster and deciding on which machines new containers should be placed. On top of that, you are responsible for managing a fleet of EC2 instances used to run the containers.

The main selling point for K8s: it is open-source and runs on AWS, Azure, Google Cloud, on-premises, or even on your local machine. The resulting disadvantage is that Kubernetes is not that well integrated with the AWS infrastructure.

Kubernetes is designed for microservice architectures. For example, a built-in service discovery allows containers to talk to each other easily by using a local proxy.

EKS is about USD 144 per month for the master layer. Besides, you are paying for the EC2 instances powering your containers. A t3.medium instance provides 2 CPUs with 4 GiB of memory and costs around USD 30 USD per month.

You should not underestimate the complexity of operating EKS and EC2. For example, the way EKS integrates with the VPC comes with a few unexpected limitations (see EKS vs. ECS: orchestrating containers on AWS for more details).

Elastic Beanstalk

Another option to run Docker containers on AWS is Elastic Beanstalk. Some say Elastic Beanstalk is the PaaS (Platform-as-a-Service) offering from AWS. Nevertheless, Elastic Beanstalk is very easy to use. There are a bunch of environments to deploy your web application with Elastic Beanstalk. One of them is called Single Container Docker. This environment deploys a single Docker container to one or multiple EC2 instances.

Elastic Beanstalk is not only deploying your application; it is also creating the needed infrastructure consisting of a database, a load balancer, and EC2 instances. Important to note: Elastic Beanstalk creates EC2 instances automatically. But you are still responsible for these virtual machines they are not fully-managed by AWS.

Elastic Beanstalk is a proprietary but free of charge solution offered by AWS. You are only paying for the underlying infrastructure. For example, a t3.medium instance provides 2 CPUs with 4 GiB of memory and costs around USD 30 USD per month.

My recommendation

My experience shows that managing the virtual machines for a dynamic container workload requires a lot of effort. The big difference between the three options discussed in this article is the service depth provided by AWS.

Three ways to run Docker on AWS

That is why I highly recommend using ECS and Fargate to run your Docker workloads on AWS. With Fargate you do not need to patch, scale, monitor virtual machines anymore. Imagine Fargate as a flexible and production-grade Platform-as-a-Service offering for Docker containers. No need to invest effort into your container platform any longer.

Want to get started with ECS quickly? Check out our book and online seminar Rapid Docker on AWS.

Andreas Wittig

Andreas Wittig

I’m the author of Amazon Web Services in Action. I work as a software engineer, and independent consultant focused on AWS and DevOps.

You can contact me via Email, Twitter, and LinkedIn.

Briefcase icon
Hire me
Cover of Rapid Docker on AWS

New book: Rapid Docker on AWS

A rapid way to get your web application up and running on AWS. Made for web developers and DevOps engineers who want to dockerize their web applications and run their containers on Amazon Web Services. Prior knowledge of Docker and AWS is not required.

Buy icon
Buy now
Marbot Logo

Incident Management for Slack

Team up to solve incidents with our chatbot marbot. Never miss a critical alert. Escalate alerts from your AWS infrastructure among your team members. Strong integrations with all parts of your AWS infrastructure: CloudWatch, Elastic Beanstalk, RDS, EC2, ...

Slack icon
Try for free
📚 Rapid Docker on AWS
A rapid way to get your web application up and running on AWS. Learn how to package your application into Docker containers. Learn more.