Objective
In this lab, you will act as a DevOps Engineer.
The developer (Jules) has already written the application and pushed the source code to GitHub.
Your responsibility is not to write the application.
Your responsibility is to package it, deploy it, and make it available to users.
By the end of this lab, you will:
- Build a Docker image
- Push the image to Amazon ECR
- Deploy the container to Amazon ECS (Fargate)
- Configure an Application Load Balancer
- Access the application through the browser
Architecture
Developer
│
▼
Application Source Code
│
▼
Docker Image
│
▼
Amazon ECR
│
▼
Amazon ECS (Fargate)
│
▼
Application Load Balancer
│
▼
Users
Scenario
Jules is a Software Developer.
He finished developing the application.
He informs the DevOps team:
"The application is ready. Please deploy it."
Now your work begins.
Step 1 – Open the Project
Open the project in VS Code.
Look at the project structure.
Example:
restaurant-app/
Dockerfile
package.json
src/
public/
README.md
Why?
Before deploying an application, a DevOps engineer needs to understand the project structure.
You should identify:
- Which programming language is used
- Which package manager is used
- Which port the application runs on
- Whether a Dockerfile already exists
Step 2 – Verify the Application
Run the application locally.
Example:
npm install
npm start
Open
http://localhost:3000
Verify the application works.
Why?
Never deploy an application you haven't tested.
If it doesn't work locally, it won't work in AWS.
Step 3 – Review the Dockerfile
Open the Dockerfile.
Example:
FROM node:20
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm","start"]
Why?
Docker packages the application and all of its dependencies into a container.
This allows the application to run consistently on any machine.
Step 4 – Build the Docker Image
Run:
docker build -t restaurant-app:v1 .
Verify:
docker images
Expected output:
restaurant-app
v1
Why?
A Docker image is a portable package containing:
- Operating System
- Runtime
- Dependencies
- Application Code
Amazon ECS runs Docker images, not source code.
Step 5 – Test the Docker Image
Run:
docker run -d -p 3000:3000 restaurant-app:v1
Open
http://localhost:3000
Verify the application loads successfully.
Why?
Always test the Docker image before pushing it to AWS.
This prevents deployment failures later.
Step 6 – Create an Amazon ECR Repository
Open AWS Console.
Navigate to
Amazon ECR
Click
Create Repository
Repository Name
restaurant-app
Click
Create
Why?
Amazon ECR is a private Docker registry.
It stores Docker images.
Amazon ECS downloads images from Amazon ECR.
Step 7 – Authenticate Docker to Amazon ECR
Run:
aws ecr get-login-password --region us-east-1 \
| docker login \
--username AWS \
--password-stdin ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
Expected output:
Login Succeeded
Why?
Docker must authenticate before pushing images into Amazon ECR.
Step 8 – Tag the Docker Image
Run:
docker tag restaurant-app:v1 ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/restaurant-app:v1
Why?
Docker needs to know where the image will be stored.
Tagging associates the image with the ECR repository.
Step 9 – Push the Image
Run:
docker push ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/restaurant-app:v1
Open Amazon ECR.
Verify the image appears.
Why?
Amazon ECS cannot deploy images stored only on your laptop.
The image must first be stored in Amazon ECR.
Step 10 – Create an Amazon ECS Cluster
Navigate to
Amazon ECS
Click
Create Cluster
Choose
Networking only (Fargate)
Cluster Name
restaurant-cluster
Create the cluster.
Why?
The cluster is the environment where containers run.
Using AWS Fargate means AWS manages the servers.
As a DevOps engineer, you don't need to install or patch operating systems.
Step 11 – Create a Task Definition
Create a new Task Definition.
Configure:
Launch Type:
Fargate
Container Image
ECR Image URI
CPU
0.5 vCPU
Memory
1 GB
Port
3000
Save the Task Definition.
Why?
The Task Definition is the blueprint for running the container.
It tells ECS:
- Which image to use
- CPU allocation
- Memory allocation
- Port mapping
Step 12 – Create an ECS Service
Inside the cluster
Click
Create Service
Select
Task Definition
Desired Tasks
1
Launch Type
Fargate
Why?
A Task runs only once.
A Service continuously monitors the application.
If the container crashes, ECS automatically starts a new one.
Step 13 – Create an Application Load Balancer
Navigate to
EC2
Load Balancers
Create
Application Load Balancer
Configure:
Internet Facing
HTTP
Port 80
Why?
Containers have private IP addresses.
Users on the internet cannot access them directly.
The Application Load Balancer receives traffic from users and forwards requests to healthy ECS tasks.
Step 14 – Create a Target Group
Create a Target Group.
Type
IP
Health Check Path
/
Why?
The Target Group monitors the health of the application.
Only healthy containers receive traffic.
Step 15 – Connect ECS Service to the Load Balancer
Edit the ECS Service.
Attach
Application Load Balancer
Select
Target Group
Container Port
3000
Deploy.
Why?
Without connecting ECS to the Load Balancer, users cannot reach the application.
Step 16 – Test the Application
Copy the ALB DNS name.
Example:
http://restaurant-alb-123456.us-east-1.elb.amazonaws.com
Open it in your browser.
Verify that the application loads successfully.
Lab Complete
Congratulations!
You have successfully completed the responsibilities of a DevOps Engineer:
- ✅ Received application code from the developer
- ✅ Built a Docker image
- ✅ Tested the container locally
- ✅ Created an Amazon ECR repository
- ✅ Pushed the image to Amazon ECR
- ✅ Created an Amazon ECS cluster
- ✅ Created a Task Definition
- ✅ Created an ECS Service
- ✅ Created an Application Load Balancer
- ✅ Deployed the application to AWS
Questions
- Why do we use Docker instead of deploying source code directly?
- What is the purpose of Amazon ECR?
- Why can't Amazon ECS run source code directly?
- What information is stored in an ECS Task Definition?
- What is the difference between an ECS Task and an ECS Service?
- Why do we need an Application Load Balancer?
- What happens if an ECS task becomes unhealthy?
- Why do we test the Docker container before pushing it to ECR?
- What would happen if the security group did not allow traffic from the ALB to ECS?
- In your own words, describe the complete deployment flow from the developer's code to the running application.
This is a beginner-friendly lab that closely reflects a real-world DevOps deployment workflow while keeping the scope focused on Docker → ECR → ECS → ALB before introducing CI/CD in later labs.
Top comments (0)