Hey, everyone.
And welcome back.
Now, in the earlier video, we were discussing about the basics of.
So in today's video, we'll go ahead and look into the practical steps involved in order to create ACR,
as well as pushing the container images.
Now, one of the prerequisites required for this practical is that you will need an easy to instance.
So this is the easy two instance where we'll be setting up Docker and we'll be pushing the image to
the ACR repository.
Now let's also quickly open up the ACR service.
Now from the Elastic Container Registry.
So generally there are public as well as private registry available.
We'll go ahead and we'll create a private repository over here.
All right.
So the visibility is private and the name, let's just call it as private ACR repo.
All right.
Once then let's go a bit down.
We'll keep everything as default and we'll go ahead and click on Create repository.
So at this stage, the repository is created and the next step is to go ahead and push the container
image to this repo.
Now, before we do that, we need to have the container image in first place.
So what we'll do, we'll go ahead and quickly connect to the instance.
So let me quickly connect to the instance here.
You can either use the SSH client from your laptop or you can use easy to connect any one of them that
works for you.
So in case if you're using easy to connect, make sure that the security group allows port 22 for everyone.
Great.
Now, one of the first thing that you will need is Docker.
Now I'm using an Amazon Linux two based army.
So installation of Docker is pretty straightforward.
Or you'll do is by install Docker.
Great.
So let's also make it full screen.
Once Docker is installed, you can just verify if Docker is running.
So in this case it is not running.
You can also make use of system CTL status Docker to verify.
All right, so you can start the Docker service.
And it will quickly do a status once more.
You see, the Docker is now active and running, so if you just run doctor, it should show you the
basic health commands.
Now what we are going to do is we want to push a Docker container image into this repository.
Now before we do that, we need to first have the image.
So we'll be pulling an image from the Docker Hub repository and then we'll be pushing it to ACR.
So the image that we'll be using for testing is Engine X and the command to pull the images.
Very simple.
It is Docker pull engine X.
So let's go ahead and use that.
I'll say Docker pull engine X.
Now note that from exam perspective you do not really need to learn the Docker commands.
The basic concept is more than enough.
Now, if you do a Docker images over here you will see that we have the engine X image that is currently
downloaded in this specific EC2 instance.
Now the next step is to push the image to the ACR.
Now when you create a ACR repository, it will basically show you the push commands.
So these are the exact set of commands that you need to run if you want to push the image to X.
So this is a very straight forward way.
Now, in case let's say that this pop up did not come up tomorrow, it generally makes a lot of updates
and you do not really see these push commands.
One alternative is you can go to the documentation directly.
So in the s here you have a page called Pushing a Docker image.
I'll also be adding the link after this video where you can try it out.
So within here, there are certain steps that they have specified over here and you can use these steps.
The difference between the documentation and this X steps is that the name of the Ex-depot is already
filled in.
For example, here you see that the private ACR repo followed by the account number followed by the
region.
Everything is pre-filled in.
However, in the documentation they have given the example.
So here you'll have to specify the account ID the region.
You'll have to manually edit this.
So that is the only difference to make.
All right.
So let's go ahead and try it out.
Now that one of the first steps is to retrieve the authentication token.
So let's copy this.
So let's clear the screen.
Let me pace this command here.
And at this stage, immediately you see, you got an error stating unable to locate the credentials
and it is asking us to run the eight of us configure command.
So what you need to do is either you can add the access and secret keys to this specific easy to instance,
or you can add an appropriate IAM rule.
Let me go ahead and add an appropriate IAM rule.
So let's quickly go to the IAM console.
We'll go to roles.
We'll create a role.
This would be an easy to role.
Let's do a next.
And let's just call it s easier role for e c to once this is, then we'll go ahead and we'll create
a role.
Once the rule is created, let's quickly open this up.
Now, this rule by itself does not really have any permission.
Now, if you wish to push the Docker image to ACL, you will need certain set of permissions.
So this is what we need to add here.
Now, within the documentation itself, they have given a sample policy, and if you look into the policy,
it is associated with the service of ACR and there are certain actions that are allowed related to put
image and others.
So let's go ahead and copy this policy.
I'll be adding this policy directly after this video so that you can reference from there.
So let's quickly create a policy here.
We'll use the JSON, I'll paste the policy, we'll review it, and I'll say ACR policy.
Let's go ahead and create the policy.
Once the rule and the policy are ready, the next thing is you will have to attach this rule to the
ec2 instance so that easy to instance can gain the permissions.
So you can go to security, modify iam role and I have multiple roles.
We are interested in x role for AC two and I'll click on update grid.
Now let's go back to the console.
We'll clear the screen.
Let's run this command once more.
And this time you see it states login succeeded.
Now the next step is to go ahead and tag your image.
So this step two is not required.
It is basically stating to build a docker image.
Now we don't want to build a docker image.
Since this is not a docker course, we'll keep it simple.
We have already pulled the image from Engine X repo, so this seems to be fine so we can directly jump
to step three.
What you need to do is you will have to tag this specific image.
So for example, currently the image repository here it states as engine X and the tag is latest.
So you'll have to create one more tag specifically related to ACR.
So let's go ahead and copy this.
And one thing that you will have to change is this one.
This part, private X repo latest needs to be changed to the name of your image.
In this case, it is engine X latest.
All right.
So let's change it.
Once you have done that, if you do a Docker images this time you see you have this image, this is
the exact image.
So 142 NB 142 NB All right.
And now we can go ahead and perform the Docker push command, so let's copy this.
So what it is stating, push this specific image to the repository, So let's run this.
So now you see it is pushing the image to easier.
Great.
Let's close this now.
If I'll open the ECL over here, you should see one image with the image tag of latest.
Great.
So with this will conclude today's video.