Deploy Containerized Applications with ECS

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

100 days of Cloud on GitHub – Read On iCTPro.co.nz – Read on Dev.to

Get the app

Here Iam using a website with nginx server to deploy on a container with the…


This content originally appeared on DEV Community and was authored by Anuvindh Sankaravilasam

DAY 31- Deploy Containerized Applications with ECS - Day Thirty One

Image tweetImage cover

100 days of Cloud on GitHub - Read On iCTPro.co.nz - Read on Dev.to

Get the app

Here Iam using a website with nginx server to deploy on a container with the help of ECR.
Let’s get the data

git clone https://github.com/anuvindhs/CLOUD-is-AWSome.git

Docker

Building a docker file

  • Lets build our NGINX docker file for our website.

  • once you have created the docker file inside the folder, copy-paste the below commands

FROM nginx:latest
COPY ./ /usr/share/nginx/html/
  • I am using VScode, check below to understand the folder structure
    Image folder

    AWS Permissions

  • Make sure you have programmatic access via AWS CLI

  • Full permissions to ECS & AmazonEC2ContainerRegistryFullAccess

ECR

Create a repository

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

Login to ECR

if you open the repo, on the right-hand side you can see an option for view push commands.
Image push commands

Now using AWS CLI login to ECR

aws ecr get-login-password --region xx-xxxxxx-xx| docker login --username AWS --password-stdin xxxxxxxxxx.dkr.ecr.xx-xxxxxx-xx.amazonaws.com

Build the docker image

docker build -t webapp-ecr-repo .

Lets tag our image with repo name

docker tag webapp-ecr-repo:latest xxxxxxxxx.dkr.ecr.xx-xxxxxx-xx.amazonaws.com/webapp-ecr-repo:latest

Lets push the image to the repository

docker push xxxxxxxxxx.dkr.ecr.xx-xxxxxxx-xx.amazonaws.com/webapp-ecr-repo:latest

if you are using PowerShell on windows please use windows commands to push the image to the repo.

Image options

ECS

Create a cluster

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

  • Enter Cluster name & EC2 instance type , am keeping it to t2.micro.
    Image clustername

  • Select the default VPC and Subnets available.

  • Also enable Auto assign public IP

Image ip

  • you can use default Security group or create a new one or can attach a Security group which is already created.
  • Now click Create Image create

Creating Task Definition

  • Click on create Task Definition & then select EC2

Image Taskdef

  • I am naming mine as Taskdef-webapp-ecr
  • Update Task memory to 128 and Task CPU to 1 vCPU, then click Add Container
    Image container

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

  • Copy your ECR repo URI from the repository and update that on the image coloumn

  • Map your ports, here its 80:80 ,

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

Run the Task

  • goto Clusters, select Task then click Run New task
    Image run a task

  • Select EC2

  • Select out Task Definition we created.

  • Select our Cluster

  • leave everything default and click Run Task
    Image task defined

Once the Task is created you will be able to see a Running Status
if you navigate to external Link you will be able to see the live website.

Image external link

Congratulations, now you have successfully configured a docker image which you have pushed to ECR and Deployed on a container with ECS.

✅Connect with me on Twitter
🤝🏽Connect with me on Linkedin
🧑🏼‍🤝‍🧑🏻 Read more post on dev.to or iCTPro.co.nz
💻 Connect with me on GitHub


This content originally appeared on DEV Community and was authored by Anuvindh Sankaravilasam


Print Share Comment Cite Upload Translate Updates
APA

Anuvindh Sankaravilasam | Sciencx (2022-05-12T09:26:53+00:00) Deploy Containerized Applications with ECS. Retrieved from https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/

MLA
" » Deploy Containerized Applications with ECS." Anuvindh Sankaravilasam | Sciencx - Thursday May 12, 2022, https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/
HARVARD
Anuvindh Sankaravilasam | Sciencx Thursday May 12, 2022 » Deploy Containerized Applications with ECS., viewed ,<https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/>
VANCOUVER
Anuvindh Sankaravilasam | Sciencx - » Deploy Containerized Applications with ECS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/
CHICAGO
" » Deploy Containerized Applications with ECS." Anuvindh Sankaravilasam | Sciencx - Accessed . https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/
IEEE
" » Deploy Containerized Applications with ECS." Anuvindh Sankaravilasam | Sciencx [Online]. Available: https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/. [Accessed: ]
rf:citation
» Deploy Containerized Applications with ECS | Anuvindh Sankaravilasam | Sciencx | https://www.scien.cx/2022/05/12/deploy-containerized-applications-with-ecs/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.