Lab Information
The Nautilus DevOps team has been tasked with setting up a containerized application. They need to create a private Amazon Elastic Container Registry (ECR) repository to store their Docker images. Once the repository is created, they will build a Docker image from a Dockerfile located on the aws-client host and push this image to the ECR repository. This process is essential for maintaining and deploying containerized applications in a streamlined manner.
Create a private ECR repository named datacenter-ecr. There is a Dockerfile under /root/pyapp directory on aws-client host, build a docker image using this Dockerfile and push the same to the newly created ECR repo, the image tag must be latest.
Lab Solutions
πΉ STEP 1: Verify Docker & AWS CLI
On aws-client, confirm Docker is running:
docker --version
Confirm AWS CLI is configured:
aws sts get-caller-identity
πΉ STEP 2: Create the ECR Repository
Run:
aws ecr create-repository \
--repository-name datacenter-ecr \
--region us-east-1
You will get output containing:
"repositoryUri": "123456789012.dkr.ecr.us-east-1.amazonaws.com/datacenter-ecr"
π Copy the repositoryUri β youβll need it.
πΉ STEP 3: Authenticate Docker to ECR
Run:
aws ecr get-login-password --region us-east-1 \
| docker login --username AWS --password-stdin \
022390610537.dkr.ecr.us-east-1.amazonaws.com/datacenter-ecr
β Expected output:
Login Succeeded
πΉ STEP 4: Build the Docker Image
Navigate to the directory with the Dockerfile:
cd /root/pyapp
# Build the image:
docker build -t datacenter-ecr:latest .
# Verify the image exists:
docker images
You should see:
datacenter-ecr latest
πΉ STEP 5: Tag the Image for ECR
Tag the image using the repository URI:
Run:
docker tag datacenter-ecr:latest \
022390610537.dkr.ecr.us-east-1.amazonaws.com/datacenter-ecr:latest
πΉ STEP 6: Push the Image to ECR
Run:
docker push 022390610537.dkr.ecr.us-east-1.amazonaws.com/datacenter-ecr:latest
β You should see layer upload progress and a successful push.
πΉ STEP 7: Verify Image in ECR
Run:
aws ecr list-images \
--repository-name datacenter-ecr \
--region us-east-1






Top comments (0)