Introduction to Docker & Amazon ECS

Introduction to Docker & Amazon ECS

What is docker? Docker is a software development platform. It’s based on the concept of containerization. It wraps the application along with all its dependencies into a single container image. This container can be deployed on any platform to run that application. So basically these applications run exactly the same regardless of where they are running or on what system they’re running on. It uses an online cloud repository called DockerHub to store all these container images.

What is a container? A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

1_bOrphmm1BtsoUc9rND7lmw.png Applications using containers Container images become containers at runtime and in the case of Docker containers — images become containers when they run on Docker Engine.

Introduction to Amazon ECS As part of container services platform, AWS provides Amazon EC2 Container Registry (Amazon ECR). Its a fully managed docker container registry. ECS stands for Elastic Container Service. It’s a container management service. Running, stopping or managing Docker containers on an ECS cluster is a piece of cake. You can launch, stop or scale any container-based applications by just making a few simple API calls. Amazon ECS can let you create consistent deployment by building sophisticated application architectures on the microservices model.

ECS also keeps a track of your instances along with their resources. In the above diagram, There is a request to run two containers. ECS will look for instances that have the resources to run these containers, download the containers from the registry and deploy them on the containers accordingly.

How ECS works? Amazon ECS consists of the following:

Task Definition Task definition is basically the blueprint describing the docker containers that are used to run the application. In our case, it will be the two docker containers, details of the images used, the CPU memory to be allocated, environment variables to be declared and used, ports to expose, etc.

Task A task is an instance of the task definition. It runs the container along with the container details mentioned in the task definition. Multiple tasks are created by a single class definition as and when required.

0_9M9wqQ7bdsj8or7x.png

Service Service defines the minimum and the maximum tasks that are running from a single task definition at any given point. In our example, if there is one task running from a task definition and if the CPU gets maxed out, ECS adds another task. At the point, the service would be 2 as two tasks are running from one task definition. ECS Container Instance And ECS Container Agent Every docker container will run on an EC2 instance. Such EC2 instances are called ECS Container Instance. Every ECS container instance will have an ECS Container Agent running on it. This agent communicates between the instance and ECS which helps in managing the running containers or even adding new ones.

Cluster We now have the task definition, tasks, and services. All we need is a platform to hosts these. That platform is the cluster. A cluster is a group of ECS container instances. A cluster can run many services. For instance, you have multiple applications as a part of your project, you can run several of them on a single cluster. This reduces the wastage of the resources and indirectly saves your money.

Features And Benefits Of Using ECS

  1. It lets you run application containers in a highly available manner across multiple Availability Zones within a Region
  2. It lets you use containers without infrastructure management.
  3. You can containerize anything and everything and let ECS manage it.
  4. It’s super secure as you can store your container images on EC2 container registry which is very safe as your images are encrypted at rest.
  5. Another amazing feature of ECS which I honestly love is that it keeps the IAM roles separate for every task. The control access to every task is very guided.