Deploying a Scalable Fast Food Web Application on AWS with Docker, EC2, ECR, ECS, and Elastic Load Balancer (ALB).


Introduction
Welcome to this comprehensive guide on deploying a containerized application using Docker, Amazon Compute Cloud (EC2), Elastic Container Registry (ECR) and Amazon Elastic Container Service (ECS). In this project, I'll walk you through the steps to build, deploy, and manage a scalable and highly available containerized application.
Prerequisites
Before starting, ensure you have the following:
Azure Account (with an active subscription)
Visual Studio Code (VS Code) – Download from code.visualstudio.com
Docker desktop
VS Code pluggins:
Aws CLI (for managing Azure resources)
Docker pluggins (for managing containers)
Project Objective
By the end of this project, you'll have achieved the following:
Use vscode to push open project files
Build Docker image of our application.
Create Elastic Container Registry and Create a repositories in aws account.
Login to Elastic Container Registry and Configure AWS CLI for authentication using the terminal on vscode.
Pushed the Docker image to Amazon Elastic Container Registry (ECR)
Containerized and deploy application using Amazon Elastic Container services {ECS) by Creating IAM role for our ECS, Ceating Task definItion, Cluster and Services.
Configured an Application Load Balancer (ALB) for traffic management and also to view our application.
Addd listener for ALB
Configure security group for ALB and paste ALB DNS to the browser to view our fast food application.
Step 1: Open your project in VS Code and create a file named Dockerfile
On Vscode click on the “Open folder” to import your project file into Vscode. to Open our terminal click on “Terminal” The terminal is where we will run all our docker commands and AWS CLI command.
Select project folder and import it into Vscode. My project folder “feane” is on my desktop select it and click on the button “Select folder”
Create a file and name it dockerfile, make sure you have the docker and AWS CLI installed as pluggins as shown in the image
Start docker desktop
We need to start Docker Desktop because it is the host application that provides the Docker engine (daemon), which is required to execute any Docker commands.
Step 2 Build Docker image of our application.
We will use nginx as our base image for this guide. The instructions have been written into the Dockerfile, and we run the command docker build -t feane . To build the Docker image.
Use the command docker image ls to list your image.
Step 3 Login into your aws account, Create Elastic Container Registry and Create a Repositories.
In the search box, search for ECR and click “Elastic Container Registry”
Click on the “Create” button to start creating your repository
Drop-down the Private registry and Click on the “Create repository” button to create a repository that stores our docker image.
Give your repository a name “feanerepository” and Click the “Create” button below to create your repository.
feanerepository as been created succesfully showing repository name and URI (inform resource identifier) of our registry**.** Click on the “feanerepository” and Click on “View push command” provided by AWS to push docker image to the registry.
Step 4 Login to ECR and Configure AWS CLI, Creating keys for authrntication. on vscode ter
Login to Elastic Container Registry and Configure AWS CLI for authentication using the terminal on vscode.
Copy and paste the first command in the aws guide to vscode terminal and press enter
Configure AWS CLI for Authentication
To configure AWS CLI for authention you need to create an Access key and a secret key. To create an access key and secret key
Click on your Account profile name (SUBAIRNURUDEEN@……) Click on “Security credentials”
Click on the “Create access Key” button
Select Command Line interface (CLI), Check the “Confirmation” and click “Next” button
Give your key a description tag “mykey” and click the “Create access key” button to create your access key
Access key created successfully.
Note: Make sure you copy your secret key to somewhere safe or download it as a .csv file because once you leave this tab, you will only have access to the access key and not the secret key.
Now we need to navigate back to our vscode terminal and run the command aws configure, you will be prompted to enter your “Access key, Secret key, Region and output format”
Step 5 Pushed the Docker image to Amazon Elastic Container Registry (ECR)
Before pushing our docker image to ECR, we need to tag it using the push command provided by aws.
Copy and paste this command to tag your docker image i.e i’ll replace “feanerepository:latest” with “feane:latest” which is the name of my image
Copy and paste the next command on the view push command to push our docker image to ECR
Docker image of our feane application was successfully pushed to Elastic Container registry
Navigate to your Elastic Container registry to comfirm image is pushed succesfully
Step 6 Containerized and deploy application using Amazon Elastic Container services {ECS) ,Create IAM role for our ECS, Create Task definItion, Cluster,Service and Load balancer.
1. Create an IAM Role for ECS
ECS needs permissions to manage AWS resources.
Steps:
Go to the IAM Console
Click on “Roles”
Click Create Role
Select Elastic Container Service and Use Case: Elastic Container Service Task. Then Next
Attach the policies :
AmazonECSTaskExecutionRolePolicy (for pulling images from ECR)
Name the role (e.g., myrole2) and Create Role.
Sucessfully created IAM role for our Elastic Container Service
2. Create a Task Definition
A task definition specifies how containers should run.
Steps:
- Go to ECS
Task Definitions → Create new Task Definition.
- Task Definition Name: e.g. feantask
Choose FARGATE (serverless).
- Task Role: Select the IAM role created earlier
Add Container:
Container Name: e.g., feanrestburger
Image URI: ECR image URL (e.g., 156041412510.dkr.ecr.us-east-1.amazonaws.com/feanrepository)
Create the Task Definition.
Task defination created successfully
3. Create an ECS Cluster
In ECS Console → Clusters → Create Cluster.
Choose AWS fargate (Serverless)
Enter Cluster name. (feanburgercluster)
Click Create.
4. Create an ECS Service
Inside the cluster → Services → Create.
Select:
Launch type (Fargate).
Task Definition ().
Cluster (feanburgercluster).
Configure:
Service name (feanburgerservice)
Number of tasks (2).
VPC & subnets.
Security groups (allow container traffic).
Load balancer (create load balancer and attach Target Group).
VPC & subnets. (Select default)
Security groups (allow container traffic HTTP and HTTPS).
Load balancer (Check load balancer box, create a load balancer and a target group)
load balancer name feanburgerloadbalancer
Target group
Create target group name and scroll down to Click Create Service.
Service has been successfully created.
Load balancer has also been created successfully.
Navigate to the search box and type “load balancer” Click on Load balancers to view our load balancer.
Add Listener to allow HTTP traffic to our Target group Load balancer
Click on feanburgerloadbalancer and Select HTTP:80 and Click on add listener.
Select your Target group and Click on the “Add” button
Listener created sucessfully. The DNS name will be pasted on our web browser to access out application after configuring security group for our load balancer.
Configure security group to allow HTTP AND HTTPS traffic to our application.
Click on Security and the Security group ID
Click on Edit inbound rule
Allow HTTP and HTTPS Click on save rules
Copy and Paste the DNS to a web browser to access our application
This project successfully deployed a scalable fast-food web application on AWS using a serverless architecture with Docker, AWS Fargate, ECR, ECS, and an Application Load Balancer (ALB). By leveraging Fargate’s serverless compute engine, we eliminated the need to manage EC2 instances while maintaining high scalability, security, and cost-efficiency.
Key Achievements:
Serverless Container Deployment with AWS Fargate: Simplified infrastructure management by letting AWS handle provisioning, scaling, and server maintenance.
Docker & Amazon ECR: Ensured consistent deployments using containerized applications stored in a secure, private registry.
Elastic Load Balancing with ALB: Improved fault tolerance by distributing traffic across multiple Fargate tasks.
Auto-Scaling with ECS: Dynamically adjusted containerized workloads based on demand, optimizing performance and cost.
Subscribe to my newsletter
Read articles from SUBAIR NURUDEEN ADEWALE directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

SUBAIR NURUDEEN ADEWALE
SUBAIR NURUDEEN ADEWALE
Hello! I'm Subair Nurudeen Adewale, a cloud computing enthusiast and the founder of Nucloud Blog. I'm passionate about sharing knowledge and insights on cloud infrastructure, security, innovation, and the intersection of technology and design. As a cloud expert with a keen eye for user experience, I explore the latest trends and best practices in UI/UX, and how they can be applied to create intuitive, user-friendly, and seamless experiences for cloud-based applications and services. Follow Nucloud Blog for the latest updates and insights from the world of cloud computing and UI/UX design.