Connect with us

AWS

AWS Container Registry

1. Create a repository

  1. Login into AWS Console
  2. Navigate to Amazon Container Services
  3. Navigate to Repositories
  4. Click create repository
  1. Fill the required details
  1. Click Create Repository
  2. The repository is created

2. Getting the Push Commands

  1. Navigate to the newly created repository
  1. Click “View Push Commands”
  2. You can see the commands

3. Login Docker Client

Make sure the user has permissions to “ecr:GetAuthorizationToken”. Otherwise you will get the below error –

An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam::526470662813:user/AWSDba is not authorized to perform: ecr:GetAuthorizationToken on resource: *

  1. Get the token

Copy past the login command.

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com
% aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com
Login Succeeded

4. Build the image and publish

For this example, we will use this repository – docker-library/python: Docker Official Image packaging for Python (github.com).

Clone the repository and build the docker image.

docker build  -f 3.9/buster/slim/Dockerfile -t python:3-8-slim .

Tag the image.

docker tag python:3-8-slim xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/python:3-8-slim

Publish the image.

docker push xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/python:3-8-slim
% docker push xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/python:3-8-slim
The push refers to xxxxxxxxx [526470662813.dkr.ecr.us-east-1.amazonaws.com/python]
a18688d0f743: Pushed 
92a2f04a63cd: Pushed 
e02f907200b6: Pushed 
5d8b6ff688d4: Pushed 
02c055ef67f5: Pushed 
3-8-slim: digest: sha256:3ba273f0f891afb882bb5ec060542a794d53eb82bb8d62a7ad0caee60dc2630f size: 1370
% 

Now you can see the image in the ECR.

Continue Reading

Trending

Copyright © 2021 Rajan Panneer Selvam. Some of the content is derived from publically available information. For some of the resources I have obtained commercial licenses and you cannot use them in your projects. Before reusing any of the site content, please double-check for copyright issues. I am not responsible if you are infringing copyrights.