AWS ECR Tutorial | Elastic Container Registry | Hands-On | Push docker image to AWS ECR

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys welcome back to my channel so in today's video I'll be talking about AWS ECR so ECR is a part of AWS ecosystem and it provides seamless integration with other AWS Services it offers scalable and reasonable available storage for Docker images so basically it's a kind of registry for your Docker images and where you can store your Docker images so today we'll be talking about it and we'll be also looking into the handson let's look into the contents of today's video so the main contents that we'll be discussing today will be what is AWS ECR uh what are the differences between ECR and dockerhub so dockerhub is also a image registry where you can store your images Docker images then accessing ECR through AWS console so this is the handson demo that we'll be looking into we will be using ECR to through AWS console and then we will be setting up ECR repository we will be using AWS CLI and and we will be configuring AWS secrets and access keys and then we'll be trying to access uh ECR repository and push the image from our local machine to uh Docker image from our local machine to the ECR AWS ECR so let's get started this video is going to be really interesting because I will be showing you Hands-On demo as well on how you can push the docker images to ECR so first thing is what is AWS ECR so let's look a quick intro about it so e R is a fully managed Docker container registry that makes it easy to store manage and deploy Docker container images so it seamlessly integrates with other AWS services and provides secure scalable storage for your container images so basically AWS ECR is used for storing your container Docker container images and it is a Docker container registry that stores your images both in public and private format now let's uh understand uh how does it actually works so basically a developer writes the code developer will write the code the code could be in any language it could be a python code or a spring boot code or any code and then the code will be packaged into a Docker image and we want to push this Docker image to a repository where it could be kept where it could be shared within organization or outside of organization so generally the main Docker registry which is being used widely by open-source projects and by different kinds of small projects also or big projects also is Docker Hub however Amazon also introduced its uh Docker uh container registry which was your ECR so once the developer writes the code uh he creates a Docker image of that code the docker image could be pushed on Amazon ECR so why Amazon ECR because it provides a lot of features it helps you in maintaining your Docker image it helps you in um scanning the image uh in image detecting the image vulnerability and image tagging image versioning and it also helps in maintaining the image life cycle so that is where we are going to use Amazon ECR and then Amazon ECR also integrates very well with other uh AWS services such as ECS eks or any other on premise Services as well so the integration is quite really good also it provides the security aspect so you can integrate IM with your ECR in order to make sure that the images that you are keeping on the ECR is quite safe and secure now let's discuss the differences between ECR and dockerhub so both are container Registries and both are used for uh storing and maintaining the container images but what are the major differences between these two container Registries we'll look into that so these are some of the points on which we will look what are the differences between each of them so the first point is X control and security ECR offers granual Access Control through AWS IM and it prioritizes security with encryption at rest and in transit along with image scanning for vulnerabilities then we have dockerhub dockerhub it provides basic exess control for private repositories and security measures might be comparatively limited it lacks the advanced IM integration extensive security features of ECR so ECR is far better off in the security when com comp to dockerhub now the next point on which we will see the differentiation between ECR and dockerhub is on integration so ECR it seamlessly integrates with various AWS services like ECS eks cloud formation and others and this allows better container management however for dockerhub it is accessible from various platforms such as AWS but it lacks the depth of integration capabilities within AWS environment if we talk about and this is something that is being offered by ECR it integrates well with the AWS Services now the third point on which we can differentiate ECR and dockerhub is storage and performance so ECR offers reasonable available scalable and secure storage within the AWS infrastructure it provides direct access to AWS services so it is integrated with AWS Services however Docker Hub it provides storage for Docker images with wearing performance but may not be optimized for AWS specific services or regions now the fourth distinction uh can be uh discussed on the topic of community and accessibility between these two container Registries that is ECR and dockerhub so ECR is primarily focused on Enterprise gate Solutions however Docker Hub is known for its vast Community Driven sharing of Docker images and applications it also offers both public and private repositories and it is more accessible to the individual developers in open source projects so that is where dockerhub comes in and it plays an important role for open source projects as well as for individual contributors then we will talk about usability and interface so ECR it integrates seamlessly with AWS Management console and it provides a familiar interface for AWS users on the other hand dockerhub it is userfriendly interface but with a straightforward approach it is accessible to users across different platforms forms and environments now the next point on which we can discuss the differences between ECR and dockerhub is cost structure so um ECR is built within the AWS ecosystem and ecr's pricing is integrated with other AWS Services following the pay as youo model for storage and data transfer so basically it cost you money when you are trying to create private repositories and it is more based on the pay as you go model ECR whereas dockerhub it offers free and paid Ty ERS both for individual and Enterprise or team use and it has different pricing structures based on private repository needs so that's the main differences between ECR and dockerhub and it's a very popular question uh devops interview questions what are the differences between ECR and dockerhub so in conclusion we can say that ECR is tailored for AWS Centric deployments and it emphasizes on security integration with AWS ecosystem and Enterprise gate Solutions whereas if we talk about dockerhub it is accessible and Community Driven and may lack the depth of security features and Native AWS integration which is being offered by ECR so the choice between the two depends on the specific needs of the users so there could be security requirements and integration preferences so if your organization is already using AWS let's say so in that case you can prefer using ECR since it provides better integration with AWS Services you can make use of IM am and you can provide a lot of security and vulnerability scanning of the images as well if you use ECR over there and then depending on the community collaboration so if you want a better Community collaboration in that case you can consider using dockerhub so these are some of the major differences between Docker Hub and ECR now let's Deep dive onto the demo part and let's see how you can push the docker images on AWS ECR so we will start with Amazon's uh console AWS console and then we will be creating a repository in ECR this is my GitHub account so we will go to AWS projects repository and over there I have AWS ECR and in this readme I have mentioned the steps that we will be following today so we will be installing AWS CLI on the local machine so I already have it installed but I will show you how you can also install AWS CLI on your machines and then you can configure AWS CLI using this command AWS configure you can create an AWS third step would be creating an AWS ECR repository then we will be I'll be showing you how you can get the commands which needs to be executed in order to uh push the docker image from your local repository to AWS ECR next we will be checking one of the docker application and you can push the docker image on AWS ECR by running few commands which we will be checking out just in a while and then once you have pushed the uh image we will be see how we will be seeing how this the image looks in the ACR repository so let's go to our AWS console so first of all what you have to do is in AWS console so I hope everyone of you have an AWS account so you you can do this in AWS free tire as well so free tire is something that provides few Services which can be used within a year by everyone who registers for this AWS account so let's look into into the AWS ECR so we will search for ECR in the search bar and then we will click on this service lastic container register service registry service and then we will click on this button get started which is just below create a repository we'll click on create repository U and then uh these are the visibility settings and now we are going to create a new repository so let's say I create a private repository and I name it as spring boot repo so that is a repository name and then we are not going to make any changes to the default settings we are just going to leave it as it is however there are certain settings which could be looked into like image scanning settings are there so you can select these settings if you want to enable the scan on push so whenever you are pushing the image there will be an image scanning that will be done then you can check on the encryption settings as well so KMS encryption that is AWS Key Management Service is is can be used to encrypt images stored in this uh repository so instead of using default encryption settings a AWS KMS Services could also be used so once you have uh once you have given the name of your repo which you want to create we will click on create repository button so now our repository is being created you can see that this is the repository now let me show you how you can install AWS CLI so you need to install that on your local and then you can run the commands uh which will help us in pushing the docker image to this particular repository so let's go over here and see so as of now there are no images that are present in this repository however we will be uh pushing some uh Docker images to this uh ECR repository let us search for AWS CLI over here and we want to uh install the AWS command line interface on our local so that we can interact with the ECR repository as well as the other services that we want to interact through command line interface so there are the three operating system options which I mentioned over here so let's say if you have Windows what you have to do is you have to download this particular uh MSI and once you download this particular MSI you just have to run that particular uh MSI and it will help you in installing AWS CLI and once you have installed AWS CLI you can check like what is the version of AWS CLA that is being installed on your local so you can check that by using the command AWS minus minus version so it says that this is being installed on my local 2.15.2 is something that is installed on my local so once you have installed on Windows the other option is you can check for Linux as well uh how you can install on Linux so they have given the steps quite nicely so you can see that to install the uh AWS CLI run the following commands in your Linux environment and to update your current installation you have to run this particular command and then uh in order to download and uh you will be unzipping this particular AWS CLI v2. zip once that is being done you have to use uh this particular command in order to install AWS on your Linux machine so that is how you install AWS on your Linux machine so once once this is being done you have installed AWS on the desired machine where you are currently working on the Mac OS you can use GUI in order to install uh the AWS CLI once you have installed it uh we will be connecting our AWS CLI to uh the to our AWS console and for that we will be using the command AWS configure and once we use this command it will ask us few information like it it will ask us to provide the exess key it will ask us to provide the secret access key and it was also ask us to provide the default region name and it will also ask us to provide the default output format which you want to see so for me I have kept it as Json and default region name I have given as us East one and once that is being done it will connect you to the AWS console so let me show you how you can also create a secret access key and an access key ID in order to connect to your uh AWS console through your AWS CLI go to our AWS console and we will search for I so IM is a service which helps you in creating new users creating of security credentials exess credentials and all those things so I've also created a dedicated video on how you can create users roles policies in I am so you can go and check out that video as well so let's go ahead and create a new user user so let's click on create user button and let's give this user as demo user the name of this particular user demo user and we will click on next so let's say we want to attach policies directly to this particular user and I want to give this particular user administrative access policy so I will go and I will give this user administrative access and then I will click on next and let's say I don't want to create any tag as a I to this particular user I will click on create user so it is that simple to create a new user in I am in AWS so once you have created this new user what you can do is you can create an access key so we will be using this access key in order to access the AWS from our AWS CLI so when uh AWS uh our AWS CLI which is installed on our local it has to interact with the AWS console there has to be a certain security mechanism or a way in which AWS can authenticate that the request that is coming from the user it is correct or not so in order to authenticate that request we are creating this exess key and secret key so let's say you select command line interface over here and you select uh I understand the above recommendation want to proceed to create an exess key and then we will click on next then uh let's say I give the tag as demo tag and then we will click on create access key so this will create my access key and it will also create a CSV file uh so it will allow you to download these credentials access key ID and secret access key which it has created and it will say download. CSV so make sure that you download the CSV so that you have your uh credentials exess key and secret access key stored somewhere and you don't have to create it once again and then you can click on done so once you have clicked on done you have created exess keys and you can see that those exess keys are uh present over here inside the user uh you go inside the user that we created demo user and then you go inside security credentials and inside security credentials you can see that exess keys are being created over here and the status of this exess key is active currently and basically you can deactivate the key if you not using it or you can delete the key as well because this is something uh an authentication mechanism or an exess key which allows any machine to access to your AWS console and um do different kinds of uh things with your services that are present on your AWS so you can keep this uh so these exess Keys should be kept secret or they should be uh deactivated if you are not using these EXs keys so let's say our exess key is active now now we are going to authenticate so we installed AWS CLI I've shown you how you can download and install AWS CLI we will go to our command line and we will once again check the version so this shows that AWS CLI is being installed next we are going to type is AWS configure this will this command will help us in configuring our um EXs key secret key and the region in which you want to configure as well as you have to give the output format so you will click on enter then it will ask you to enter the access key ID so let's say you enter this access key ID and then it will ask you to enter secret access key so let's say you enter another secret access key uh the access key that you just downloaded so you can go to your downloads and you can get that secret access key and you enter that and you hit enter and then you have to enter the default region so you will enter the default region and then you have to enter the output format in order to configure and then you will hit enter so that is how you are going to uh authenticate the user and you are going to make sure that uh you are able to access the AWS services from your local machine so I'll pause the video here and I will uh go back and configure correctly for the user that I'm using currently this was just to show you a demo part of how you can configure your AWS access keys and secret Keys now we have configured the IM access keys and secret keys with in our local also so next thing that we can do is uh you can check one of my project and you can clone that project it is a dock R Spring boot application so this project can be cloned and then we are going to push this particular uh Docker image of this project on our AWS ECR so you can clone this repository and then you can make use of it so in a while I will show you how you can push it to ECR so the next thing is like like if I go to Spring boot uh repo and I select this particular repository then you can see that over here there is a button with name view push buttons we will click on it view push commands we will click on it and we are going to use these particular commands in order to push our image to the to the ECR repository so the first command is what it does is it retrieves an authentication token and authenticates your Docker client to your registry so that is what this particular command does then the next thing is it builds your Docker image so we are going to use this particular command then the third command is after the build completes tag your image so you're going to tag your image using this command so you can push the image to the repository and then run the following command to push the image to the newly created AWS repository so let's run this commands and see how it looks uh this is my uh location where I have kept the project so we will open the command line from this location and then we will run the commands that are mentioned in our push on commands so let's copy this command and let's try running this command so I have copy pasted that command and I will hit enter over here so this will so this there is an error so it says that this error May indicate that the docker demon is not running so we have to make sure that Docker is installed on our local and Docker is always uh is running when we are running this particular command so let me start Docker uh so I have just started Docker and let's see if it runs then we can uh run these commands so it takes a few seconds to initialize the docker engine and Docker in my local so you can see that it says starting the docker engine so I installed Docker desktop uh Docker setup is being done on my local let's run this command once again and see so it says login succeeded so the docker is also running in my local so it says Docker desktop running uh you can see the small icon here which says that the docker desktop is running Docker demon is running on the background now the next command that we are going to copy is Docker build minus t spring boot report dot so we copied this command so this would build our Docker image so let's run this particular command so it is building the image you can see that it is building the image all the layers and everything and once this is being built we will run the third command Docker tag in order to tag our image so that we can push it to the repo so we will run the third command just copy the commands let's copy the command once again then we will hit enter so this is Tag the image now let's push the image to our AWS ECR we copied the command and we are going to push the image so let's see it is pushing the image currently and that is what it says that it is pushing the image so once this image is pushed on our AWS ACR repository we can see that it contains uh the image and there will be this image that will be placed over there so it takes few seconds to push it to AWS ECR as you can see that the image is being completely pushed on AWS ECR we will go back and now check that whether the image is present on AWS ECR repo or not okay so we used all these commands in order to push the image to ECR repository let's go into our ECR repository and you can see that the image has been pushed on this particular location and uh the images present on this particular uh in this ECR repository that we just created so that's it for today I hope you enjoyed today's video and it was informative for you so if you liked the video and the content please consider subscribing to our Channel thank you bye-bye
Info
Channel: Tech with Neha Garg
Views: 2,568
Rating: undefined out of 5
Keywords: AWS ECR Tutorial | Elastic Container Registry | Hands-On | Push docker image to AWS ECR, how to push an image to aws ecr
Id: NqmtBPoFYo0
Channel Id: undefined
Length: 24min 25sec (1465 seconds)
Published: Mon Dec 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.