Skip to content

AWS ECS

AWS ECS (Elastic Container Service) is a managed container orchestration platform that enables fast deployment and scaling of containerized workloads.

Docker containers management on AWS

  • Amazon Elastic Container Service (Amazon ECS)
  • Amazon Elastic Kubernetes Service (Amazon EKS)
  • AWS Fargate (serverless)
  • Amazon ECR (store container images)

Amazon ECS cluster

An Amazon ECS cluster is a logical grouping of tasks or services. Your tasks and services are run on infrastructure that is registered to a cluster. The infrastructure capacity can be provided by:

  • AWS Fargate, which is serverless infrastructure that AWS manages
  • Amazon EC2 instances that you manage
  • On-premise server or virtual machine (VM) that you manage remotely

A cluster may contain a mix of tasks hosted on AWS Fargate, Amazon EC2 instances, or external instances

EC2 Launch Type

The EC2 launch type allows you to run your containerized applications on a cluster of Amazon EC2 instances that you manage.

AWS ECS Cluster using the EC2 Launch Type

Fargate Launch Type

The Fargate launch type allows you to run your containerized applications without the need to provision and manage the backend infrastructure. Just register your task definition and Fargate launches the container for you. (serverless)

  • You just create task definitions
  • AWS just run ECS tasks for you based on the CPU/RAM you need
  • To scale, just increase the number of tasks.

Load Balancer Integrations

-

How to route traffic to your Docker container in AWS ECS using an Application Load Balancer

EC2 Launch Type

  • We get a Dynamic Host Port Mapping if you define only the container port in the task definition
  • ALB finds the right port on your EC2 instance
  • We must allow on EC2 instance's Security Group any port from the ABL's Security Group

Fargate

  • Each task has a unique private IP
  • Only define the container port (host port is not applicable)

Data Volume

ECS Service Auto Scalling

Task definition

Task definition are metadata in JSON form to tell ECS how to run a Docker container.

It contains crucial information, such as:

  • Image name
  • Port binding for Container and Host
  • Memory and CPU required
  • Environment variables
  • Networking information
  • IAM role
  • Logging configuration (CloudWatch)

We can define up to 10 contains in a Task Definition

Amazon ECR

Amazon ECR is a fully managed container registry offering high-performance hosting, so you can reliably deploy application images and artifacts anywhere.

Amazon EKS

Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that you can use to run Kubernetes on AWS without needing to install, operate, and maintain your own Kubernetes control plane or nodes.