In the DevOps workflow for containers, it's pretty clear that a container registry is pretty core to the system. As soon as you start developing, you're pulling images, so that you can build your images locally and test them. You push them to your CI system, and when you build those images, you're pulling base images and you're pushing them back. When you're deploying, the images come from the container registry to deploy to one of many different container or container targets.
In this post, I am going to walk you through why and how to create a container registry in Azure.
First, let’s see why Azure Container Registry.
-To have a Private Image Repository
Docker hub in the default registry for Docker and allows to push your images to a public registry. But in your company you may want to keep your images within your datacenter as they are private to your organization. Please note that you can also use the private registry in Docker hub as well, but we will see what are other benefits using Azure container Registry.
-Integration with Azure Active Directory
You might want to use your active directory groups to manage who has access, so that your development team has push and pull rights, but other teams that use your images have just pull rights.
You may want to have them network close so that when you are doing pushes and pulls, the physical network latency is just going to be shorter because it is right there in your datacenter. You are not going to have charges e.g. ingress and egress because they are within the data center, and their latency is shorter.
-Command Line Interface
You have a familiar experience with the CLIs. Azure team stayed true to the Docker CLIs for different docker commands e.g. docker login, docker push, docker pull, so that you're going to have a common experience that you're used to.
Now that we’ve answered to the why question, let’s jump into how to create an Azure Container Registry in Azure Portal and push a local image to it.
After login in to Azure Portal, Container Registries as below screenshot and click on the Create button.
You will need to enter registry name along with other required field.
After creating the registry in Azure, click on it to see more details.
As you can see on this screenshot, we have registry name, login server, user name and password which we will use them to push a local image.
Now, let’s push an image from local computer to our new registry in Azure. In order to push an image we need to login to the registry using login server, username and password from previous screenshot:
Docker login login_server –u user_name -p password
When you are pushing an image to registry, you need to tag an image to the fully qualified name of your target:
Docker tag image_name server_name/tag_name
Now, we can start pushing image to the azure container registry:
Docker push server_name/tag_name
Now that we’ve pushed our image to the repository, we can login to Azure Container Registry Web Portal to view our image:
And by clicking to the image and then the tag we can see the layers that made up that image:
To conclude, we have seen what are benefits of Azure Container Registry and how to create an Azure Container Registry in Azure Portal and how to push a local image to it.