Journey through AWS ECS – container orchestration service

Journey through AWS ECS – container orchestration service

What is AWS ECS

AWS ECS is a “container management service managed by AWS which lets you run, scale and monitor docker containers easily”, it means AWS ECS runs and manages docker container cluster on your behalf and ensure the containers are up and running all the time.

Why use AWS ECS

Why should one opt for AWS ECS when there are tools like Kubernetes, docker swarm readily available. The main reasons are listed below:

  1. Runs and manages containers on your behalf
  2. Make sure the number of running containers is met as per described in the definition
  3. Replaces unhealthy container with healthy one automatically
  4. Enables containers scaling based on the definition
  5. AWS ECS agent tracks the CPU and memory of the host machine by default so scaling the host machines is a piece of cake
  6. Deployment of new container is super easy and super fast

AWS ECS terminology

There few components that govern the functioning of AWS ECS.

  1. ECR: AWS manages docker images repository to keep all your docker images secure and highly available
  2. Clusters: As the name suggests this is an ECS cluster which comprises all the required services to run your containers.
  3. ECS Instances: The EC2 instances which have docker engine and AWS ECS agent installed and are part of your cluster.
  4. AWS ECS agent: The ECS agent which keeps track of the running containers and send the report to ECS Server.
  5. Task definitions: The definition describing the schema and attributes of the container to be run
  6. Services: The container daemon which runs and is readily available to accept requests.
  7. Tasks: The actual running containers
  8. Scheduled Task: This is like a cron which can run at a specific time with specified frequency.

AWS ECS console

 This is how AWS ECS console looks like


How to get started with AWS ECS

Now as we have been through the ECS terminology lets get our hands dirty and run our service on AWS ECS. To start we will perform below steps:

  • Create a repository on ECR
  • Create your docker image that needs to be run
  • Push your docker image to ECR
  • Create a task definition to be consumed by the service
  • Create an ECS cluster
  • Create a service
  • Last but not the least — see your service up and live on a highly available cluster with peace of mind

Will perform this process step by step :

Create a repository on ECR

  1. Login to AWS Console and go to ECS section.
  2. Select Repositories under AWS ECR
  3. Enter your desired name but as per standards the should be {namespace}/{repo name}  i.e devinitiate/demo click next.
  4. Follow the wizard and you will get the commands to tag your image and to push the image to your AWS ECR repository.


Create your docker image that needs to be run

In this step, we build a Docker image which needs to be deployed on ECS. Let’s spin a very basic Nginx image which welcomes you with hello world!! message. To build a Docker image you need a Dockerfile which contains all the docker build-related information. Our docker build is as below:

From nginx

Well, that is very short declaration but is good enough to start with docker.

Push your docker image to ECR

Now using the commands displayed in your ECR console build, tag and push the images to AWS ECR.

Create a task definition to be consumed by the service

Now we will create a task definition that will be used to start docker container.  Task definitions contain multiple parts that control the various aspects of your service like CPU, RAM and volume mounting etc. Some components are required like family meanwhile some are optional.  The major components of task definitions are:

  • Family   
    • This is an identifier for your task definition which can have multiple versions. It’s required for task definition.
  • Network Mode
    • Defines how the networking is to be used for your container. Most commonly bridge bode is used which is the default mode. As a default mode is set this field is optional.
  • Container Definitions
    • Manages the docker repo and image to be used. It also contains information like CPU, RAM and port mappings. This is a very crucial part of the task definition hence a required field.
  • Volumes
    • Mentions the volume mounting from host to docker image. Docker can run without this information hence this is optional.

Using the above information we will create our task definition for the Nginx image. AWS has a very intuitive console for creating the task definition. Log on to the AWS ECS Console and go to ECS

For getting started quickly just provide below information :



Save the configuration. You have created your task definition. Now it’s time to create your ECS cluster.


Create an ECS cluster

To make life easy for docker enthusiast and get started quickly AWS came with a very good idea to provide a wizard to create and configure a complete stack with hosts (ec2 instances), ELB (application load balancer in this case ), deployment mechanism with no efforts etc. It is very easy to launch a cluster which can run docker container via the AWS console.

Go To AWS ECS and select Create Cluster under cluster section. Select the cluster template which suits your need and provide the information like cluster name, instance type, number of instances etc and voila your cluster is ready to run Docker images.

Create a service

Time to bring Frankenstein to life. We will create a service which will make all our efforts fruitful and run the highly available docker cluster.

  • Select your cluster
  • Select create under service section
  • Provide information like task definition to be used (devinitiate in our case )
  • Follow the wizard and fill in information like service name, number of task, placement strategy.

Once done you have created your first service.


If you see this output when you hit your alb used for ECS time to say IT’s alive!!! 

Hope this tutorials helps you to create and run docker.

One Reply to “Journey through AWS ECS – container orchestration service”

Leave a Reply

Your email address will not be published. Required fields are marked *