Deploy Containerized Applications with ECS

DAY 31- Deploy Containerized Functions with ECS – Day Thirty One

Image cover

100 days of Cloud on GitHubRead On – Learn on

Get the app

Right here Iam utilizing a web site with nginx server to deploy on a container with the assistance of ECR.
Let’s get the info

git clone
Enter fullscreen mode

Exit fullscreen mode


Constructing a docker file

  • Lets construct our NGINX docker file for our web site.

  • upon getting created the docker file contained in the folder, copy-paste the under instructions

FROM nginx:newest
COPY ./ /usr/share/nginx/html/
Enter fullscreen mode

Exit fullscreen mode

  • I’m utilizing VScode, test under to grasp the folder construction
    Image folder

    AWS Permissions

  • Be sure to have programmatic entry through AWS CLI

  • Full permissions to ECS & AmazonEC2ContainerRegistryFullAccess


Create a repository

  • Goto ECR from AWS console and create a repository
  • Create a ECR repo ,i’ve named mine webapp-ecr-repo

Login to ECR

for those who open the repo, on the right-hand facet you possibly can see an possibility for view push instructions.
Image push commands

Now utilizing AWS CLI login to ECR

aws ecr get-login-password --region xx-xxxxxx-xx| docker login --username AWS --password-stdin
Enter fullscreen mode

Exit fullscreen mode

Construct the docker picture

docker construct -t webapp-ecr-repo .
Enter fullscreen mode

Exit fullscreen mode

Lets tag our picture with repo identify

docker tag webapp-ecr-repo:newest
Enter fullscreen mode

Exit fullscreen mode

Lets push the picture to the repository

docker push
Enter fullscreen mode

Exit fullscreen mode

in case you are utilizing PowerShell on home windows please use home windows instructions to push the picture to the repo.

Image options


Create a cluster

  • Goto ECS dashboard and click on Create Cluster.
  • choose EC2 Linux + Networking
    Image ec2

  • Enter Cluster identify & EC2 occasion sort , am protecting it to t2.micro.
    Image clustername

  • Choose the default VPC and Subnets obtainable.

  • Additionally allow Auto assign public IP

Image ip

  • you should utilize default Safety group or create a brand new one or can connect a Safety group which is already created.
  • Now click on Create
    Image create

Creating Job Definition

  • Click on on create Job Definition & then choose EC2

Image Taskdef

  • I’m naming mine as Taskdef-webapp-ecr
  • Replace Job reminiscence to 128 and Job CPU to 1 vCPU, then click on Add Container
    Image container

  • Add a reputation, mine is container-webapp-ecr

  • Copy your ECR repo URI from the repository and replace that on the picture coloumn

  • Map your ports, right here its 80:80 ,

  • Now add, and create the Job definition.
    Image task def create

Run the Job

  • goto Clusters, choose Job then click on Run New activity
    Image run a task

  • Choose EC2

  • Choose out Job Definition we created.

  • Choose our Cluster

  • depart every thing default and click on Run Job
    Image task defined

As soon as the Job is created it is possible for you to to see a Working Standing
for those who navigate to exterior Hyperlink it is possible for you to to see the stay web site.

Image external link

Congratulations, now you’ve gotten efficiently configured a docker picture which you’ve gotten pushed to ECR and Deployed on a container with ECS.

✅Join with me on Twitter
🤝🏽Join with me on Linkedin
🧑🏼‍🤝‍🧑🏻 Learn extra submit on or
💻 Join with me on GitHub

anuvindhs image

Add a Comment

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