6

Lab Guide:Amazon Elastic Container Registry (Amazon ECR)

 1 year ago
source link: https://blog.geekyants.com/lab-guide-amazon-elastic-container-registry-amazon-ecr-22ad8efb1a6a
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Lab Guide:Amazon Elastic Container Registry (Amazon ECR)

Let’s take you through AWS managed container image registry.

0*8ETs2nJt63immsZf

Container Management

AWS managed container image registry is secure, scalable, and reliable. The Amazon ECR supports private repositories with resource-based permissions using AWS IAM. This ensures that specified users or Amazon EC2 instances can access your container repositories and images. You can use your preferred CLI to push, pull, and manage Docker images, Open Container Initiative (OCI) images, and OCI-compatible artifacts.

Follow the above steps:

Step 1: Create an Ubuntu Server/Instance and SSH into it.

0*BIL91mS_zaq-rofu

Step 2: Select the instance and click on Actions.

0*x4CRJEC3fPrCK8wX

Step 3: Click on Security and then click on Modify IAM role.

0*CTO3g9pjQmB2qyvh

Step 4: Click on create new IAM role.

0*EomvTXxmDKfil2cB

Step 5:Click on Create Role.

0*djsrJ6GcAav3mVR5

Step 6: Choose EC2 and click on next.

0*h2Vsz7ldojaZGLAX

Step 7: Attach ECR and EKS policies to the role and press next : same way attach ECR and EKS full access to IAM User also.

0*Rz3r6r7EC7JrF1c9

Step 8: Provide the role name.

0*TK8YlHITAnoXkqq7

Step 9: Click on create role.

0*1vjebTXhi-VFjdvd

Step 10: Come back to the instance and attach the IAM role to the instance and click on “Update IAM role”.

0*JMrGZQfFmiN6DVQo

Step 11: SSH into the server/Instance.

0*30cVt24nUEcf3jtI

Step 12: Become Root User.

sudo su
0*Q9_yPceUSzpVewfM

Step 13: Install AWS CLI(Command line Interface).

sudo apt-get updatesudo apt-get install awscliaws –version
0*5bsas-2gQ9TauROW

Step 14: Configure the AWS CLI.

Note: Use the following command.

aws configure

Note: Provide environment variables such as (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION).

0*nZd5fyy6OGRWFtA4

Step 15: Install Docker.

apt-get update -ywget -qO- https://get.docker.com/ | shdocker versionservice docker startip a
0*lpyhxbhLpL7Au4ih

Step 16: Create a Container Repository.

aws ecr create-repository --repository-name hello-world
0*Al4dlzIowYFPxIVu

Step 17: Go to AWS Container Registry service, their one repository will be created by the name hello world.

0*CGfTqJGeobXAIJ9v

Step 18: Login to the repo using below command.

aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
0*V0dfDZ-xcYdvEqPX

Step 19: Pull an image from docker hub.

docker pull hello-world
0*DXZKxqYV37MMamrj

Step 20: Tag the image to push to your repository.

docker tag hello-world: latest aws_account_id.dkr.ecr.region.amazonaws.com/hello-world:latest

Note: replace underlined words region and aws_account_id with your region and account ID.

Step 21: Push the image.

docker push aws_account_id.dkr.ecr.region.amazonaws.com/hello-world:latest

Note: replace underlined words region and aws_account_id with your region and account ID.

0*4MiGkHyosiGYOOHJ

Step 22: Go to container registory service in AWS and check “the hello-world image would be pushed” with the tag name “latest”.

0*2-L5ErMgomUAe2Kv

The above diagram shows the image has been pushed to the registry [Amazon ECR] which makes easier for us to create a container anytime using above image in the registry.

You can further read: Reference for ECR using CLI


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK