Skip to content

explicit-logic/aws-module-9.5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Module 9 - AWS Services

This repository contains a demo project created as part of my DevOps studies in the TechWorld with Nana – DevOps Bootcamp.

https://www.techworld-with-nana.com/devops-bootcamp

Demo Project: Create repository on AWS and push to private Docker registry Technologies used: Docker, Amazon ECR

Project Description:

  • Create private Docker registry on AWS (Amazon ECR)
  • Tag and Push Docker image to this private repository

Step 1 — Create a Private Docker Registry on AWS (Amazon ECR)

  1. In the AWS Console, navigate to Elastic Container Registry (ECR)
  2. Click Create repository
  3. Set the repository name to app and click Create
  4. Open the repository and click View push commands to see your registry URI and authentication steps

Note: The registry URI follows the format <account-id>.dkr.ecr.<region>.amazonaws.com

Step 2 — Create a Dedicated IAM User for ECR Access

Avoid using root credentials. Instead, create a scoped IAM user.

In the AWS Console, go to IAM → Users → Create user:

Field Value
User name ecr-user
Permission strategy Add to group

Create a new IAM group:

Field Value
Group name ecr-group
Permissions policy AmazonEC2ContainerRegistryFullAccess

Generate an access key for CLI access:

  1. Go to the user → Security credentialsCreate access key
  2. Select use case: Command Line Interface (CLI)
  3. Download the .csv file — store it securely, you won't be able to retrieve the secret again

Configure the AWS CLI with a named profile:

aws configure --profile ecr

Enter the credentials from the downloaded .csv:

AWS Access Key ID [None]:     <from csv>
AWS Secret Access Key [None]: <from csv>
Default region name [None]:   <region>       # e.g. us-east-1
Default output format [None]:                # leave blank or use json

Authenticate Docker to ECR:

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

Note: The ECR login token expires after 12 hours — re-run this command if you get an authentication error.

Step 3 — Build, Tag, and Push the Docker Image

Build the image (targeting linux/amd64 for EC2 compatibility, even on Apple Silicon):

docker build --platform linux/amd64 -t app:1.0 .

Tag the image with the full ECR registry URI:

docker tag app:1.0 <account-id>.dkr.ecr.<region>.amazonaws.com/app:1.0

Push the image to ECR:

docker push <account-id>.dkr.ecr.<region>.amazonaws.com/app:1.0

Or use the provided helper script to do all three steps at once:

AWS_ACCOUNT_ID=123456789012 AWS_REGION=us-east-1 ./push.sh

About

Create repository on AWS and push to private Docker registry

Topics

Resources

Stars

Watchers

Forks

Contributors