How to deploy Containerized Applications with Amazon ECS

Nidhi
5 min readMar 29, 2021

In this blog, we will deploy a docker container in Amazon ECS(Elastic Container Service) using ECR ( Elastic Container Registry)

Prerequisite

  1. Configure aws credential
  2. Install aws cli version 2
  3. Clone this git repo
  4. Local workstation ( I am using AWS EC2 instance)

Agenda:

  1. Create and Push to ECR repository
  2. Create a ECS cluster
  3. Create a Task Definition
  4. Run the task
  5. Create a Service

Create a ECR repository

Go to AWS > ECR > Create a repository

Click on your repository

View push commands

You will see the below commands to push your docker image to the ECR repository

clone the git repodocker build -t sample_ecs .
docker tag sample_ecs public.ecr.aws/w0f5g4k6/deploy:v7'
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS -p $(aws ecr get-login-password --region us-east-1)docker push public.ecr.aws/w0f5g4k6/deploy:v7

Run the image locally to test

docker run -it --rm -d -p 8089:8080 --name samplenginx_c public.ecr.aws/w0f5g4k6/deploy:v7

You should be able to open the url http://localhost:8089/LoginWebApp-1

Create ECS Cluster

These are the four critical items in ECS you need to know:

--

--