🧪 Day 01: Lab 1 & Lab 2 – AWS EC2 and Docker ECR Deployment....

4 min read
logo

Overview

This lab series focuses on foundational cloud and DevOps skills using AWS and Docker. The goal is to understand how to provision and configure cloud infrastructure, containerize an application, and manage container images using AWS Elastic Container Registry (ECR).

Lab 1: Setting up an AWS EC2 Instance for Docker

Objective

Learn how to provision and configure an AWS EC2 instance suitable for Docker deployments.

Tasks

  1. Launch an EC2 instance
  2. SSH into the instance
  3. Install Docker

Task 1: Launch an EC2 Instance

Use the AWS CLI to launch an EC2 instance. This step includes choosing an Amazon Machine Image (AMI), selecting an instance type, and configuring security groups and key pairs.

Task 2: SSH into the Instance

Once the instance is running, connect via SSH:

ssh -i "your-key-pair.pem" ubuntu@your-ec2-public-ip

Replace your-key-pair.pem with your private key file and your-ec2-public-ip with your EC2 public IP address.

Task 3: Install Docker

Run the following commands to install Docker on your EC2 instance:

# Update the package database
sudo apt update -y

# Install Docker
sudo apt install docker.io -y

# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker

Docker should now be installed and running on your EC2 instance.

Concepts Covered…💪🏻

  • AWS EC2 (Elastic Compute Cloud): Virtual servers for scalable compute in the cloud.
  • SSH (Secure Shell): Secure protocol for remote server access.
  • Docker: Platform for building, deploying, and managing containerized applications.

Outcome…👇

By completing this lab, you gain hands-on experience in provisioning cloud instances, establishing secure connections, and preparing an environment for Docker-based deployments.

Jump to the Next one…

Lab 2: Building and Pushing a Docker Image to AWS ECR

Objective

Build a Docker image and push it to AWS Elastic Container Registry (ECR) for secure storage and deployment.

Tasks

  1. Install Docker
  2. Install AWS CLI
  3. Create a Dockerfile
  4. Build the Docker image
  5. Authenticate AWS ECR
  6. Create an ECR repository
  7. Tag the Docker image
  8. Push the Docker image to ECR
  9. Verify the image in ECR

Task 1: Install Docker

Install Docker on your local machine or Ec2 if it’s not already installed.

Check out the link Download Docker

Task 2: Create a Dockerfile

Create a Dockerfile in your project directory or use this repo Project Repo.

# Step 1: Build React app
FROM node:20-alpine AS build

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build

# Step 2: Serve with NGINX
FROM nginx:alpine

COPY --from=build /app/build /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

Task 3: Build the Docker Image..

docker build -t myapp:latest .

Task 4: Authenticate to AWS ECR

Authenticate Docker with your AWS account:

aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <your-account-id>.dkr.ecr.<your-region>.amazonaws.com

Task 5: Create an ECR Repository

Create a new repository in AWS ECR to store your Docker image.

Task 6: Tag the Docker Image

docker tag myapp:latest <your-account-id>.dkr.ecr.<your-region>.amazonaws.com/myapp:latest

Task 7: Push the Docker Image to ECR

docker push <your-account-id>.dkr.ecr.<your-region>.amazonaws.com/myapp:latest

Task 8: Verify the Image in ECR

Check your AWS ECR console to verify the image upload.

Outcome

By completing this lab, you learned how to:

  1. Build custom Docker images
  2. Authenticate and interact with AWS ECR
  3. Manage container images for deployment on AWS services like ECS and Fargate

Final Thoughts…💭

These labs provided hands-on experience with fundamental DevOps workflows — from provisioning servers and securing access to containerizing applications and managing images in the cloud. The next step is to deploy these containers using Amazon ECS and AWS Fargate for scalable, managed orchestration.

✍️ Written by Muhammad Ishaq

📌 Follow me for more:…

Muhammad.Ishaq

© 2026 All Rights Reserved.

Made with mdishaq 🖤

LinkedIn 𝕏 GitHub