Amazon Elastic Container Registry (AWS ECR) is a container registry service where you store, manage, share, and deploy your container images (like DockerHub). Consider it as npmjs of containers instead of JS packages. AWS ECR lets you publish private as well as public images.
Before you proceed, it's assumed that you already have a containerized application. If you don't have one, you can clone this sample nodejs application.
Sign in to your AWS console and search for AWS ECR
From the AWS ECR console, click 'Get Started'
Options
Visibility settings: select Private or Public
Repository name: give any meaningful name
Tag immutability: when enabled, it will prevent tags from being overwritten by new pushes (when pushed with the same tag)
Enable Image scan setting to enable vulnerability scan after the image is pushed
Enable to use AWS KMS for encryption
Once the repository is created, it will take you back to the repositories list. Select the newly created repository and then click on the "View push commands" button.
Now you need to use these commands one by one to build, tag, and push your container image. But before proceeding make sure you have the latest version of AWS CLI installed.
Use the following command to check that AWS CLI is correctly installed on your system.
aws --version
It would output something like this. Your version could be different, it depends when you are reading this article.
Next, you need to create 'Access Keys'. For that, go to "My Security Credentials" from the dropdown with your username.
Click on "Create New Access Key", it will create a new key for you.
Copy "Access Key ID" and "Secret Access Key"
Now go back to your terminal and enter the following command
aws configure
It will ask for "Access Key ID" and "Secret Access Key", "Default region", provide them one by one. You can skip the default output format.
Once the AWS CLI has been configured, you can run the push commands. Open up the terminal and make sure you are inside the containerized app's root directory. Run each command shown in the popup opened up by clicking the "View push commands" button. Please note that the commands in the screenshot could be different than what you see in your popup and it's totally fine.
*If your 'Dockerfile' is named something other than 'Dockerfile', you will have to specify it using -f
flag (see below).
Let's connect:
Linkedin: https://www.linkedin.com/in/mubbashir10/
Twitter: https://twitter.com/mubbashir100
Top comments (0)