Pushing an image to ECR
What is ECR?Why we use it?
Amazon Elastic container Registry(ECR) is fully-managed Docker container registry that makes it easy for developers to store,manage and deploy Docker container images.
Lab:Push the image to ECR:
Go to the aws console
Select ECR dashboard
Click on Create repository
Give a name to repository
Click on Create repository
Select repository click on view push commands
Click on view push commands
You will get a page like this.
Copy the commands which are there
$(aws ecr get-login-no-include-email-region us-east-2)
docker tag nodejs:latest 529087098264.dkr.ecr.us-east-2.amazonaws.com/nodejs:latest
docker push 529087098264.dkr.ecr.us-east-2.amazonaws.com/nodejs:latest
Now tag the image
docker tag nodejs 529087098264.dkr.ecr.us-east-2.amazonaws.com/nodejs:1
then push the image
docker push 529087098264.dkr.ecr.us-east-2.amazonaws.com/nodejs:1
Before this login to the git bash to do tag and push the image
Before this create a role and add to the instance which you created to give the permissions
Go to IAM dashboard
Click on roles
Create a role
Click on create a role
Select EC2 instance to give role
Click on next permissions
Select the policy which you to the permission as per now gives the administration access
Then click on tags
Click on Review
Give a name to the role
Then click a create a role
Now go to instance which you have created
Select the instance click on actions
Select attach/replace IAM role
Select the role which you have created.
Then click on apply
Now go to the git bash connect to the instance
Login to the ECR
Use the following command
#awsecr get-login-no-include-email-region us-east-2
Now copy the text and paste and enter
Now tag the image
#docker tag nodejs 529087098264.dkr.ecr.us-east-2.amazonaws.com/nodejs:1
Now push the image
docker tag nodejs 529087098264.dkr.ecr.us-east-2.amazonaws.com/nodejs:1
Now go the ecr dashboard select the repo whether the image is pushed or not.
Execrise:Build an images of httpd,flask app,react js app ,and push the image to ECR.
Comments
Post a Comment