azure-container-registry

Azure Container Registry (ACR)

What is Azure Container Registry (ACR) for

Azure Container Registry  (ACR) is a private registry service for building, storing, and managing container images and related artifacts like as Dockerhub. The diffeernce between ACR and Doclerhub is that dockerhub is free for developers  for public Repos (even private), but ACR is private and you should pay for it. Enterprises don’t want to have their containers on a public share. They can either buy an enterprise plan or they can use a private registry like Azure Container Registry (ACR).

In this post, I create an Azure container registry instance with the Azure portal. Then, use Docker commands to push a container image into the registry, and finally pull and run the image from your registry.

To log in to the registry to work with container images, the requirement is that you are running the Azure CLI (version 2.0.55 or later recommended). Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI.

You must also have Docker installed locally. Docker provides packages that easily configure Docker on any MacWindows, or Linux system.

Create a container registry

Sign in to Azure

You should have an Azure account. Sign in to the Azure portal at https://portal.azure.com.

Select Create a resource > Search for container registry as following image:

azure-container-registry-1.png
Create Container Registry (ACR) in Azure portal

Press to the Container Registry

In the Basics tab, enter values for Resource group  and Registry name : mehzanContainerRegistry. The registry name must be unique within Azure, and contain 5-50 alphanumeric characters.  Here I am creating a new resource group: mehzanRSG i with name: mehzanContainerRegistry, in the North Europe,  , and for SKU, select ‘Basic’.

azure-container-registry-2.png
creating a basic Container Registry with name mehzancontainerRegistry

press to t he Review + Create button and then Create button, it takes a little time and then shows that Container Registry is deployed, as showing in the following image:

azure-container-registry-3.png
Container Registry is deployed

Press to Go to Resouce button then shows the overview of mehzancontainerRegistry as follow.

Tip: In this quickstart, you create a Basic registry, which is a cost-optimized option for developers learning about Azure Container Registry. Choose other tiers for increased storage and image throughput, and capabilities such as connection using a private endpoint. For details on available service tiers (SKUs), see Container registry service tiers.

azure-container-registry-4.png
ACR: mehzancontainerRegistry is created

Ok now we have created an ACR with name mehzancontainerregistry.

Take note of the registry name and the value of the Login server (mehzancontainerregistry.azurecr.io).  which is a fully qualified name ending with azurecr.io in the Azure cloud. You use these values in the following steps when you push and pull images with Docker.

Log in to registry

Before pushing and pulling container images, you must log in to the registry instance. Sign into the Azure CLI on your local machine, then run the az acr login command. Specify only the registry resource name when logging in with the Azure CLI. Don’t use the fully qualified login server name.

If you haven’t install Azure CLI ( look to: How to install the Azure CLI). After installation open command line in your local machine and run:

az login

then you can have the following propmt:

azure-container-registry-5.png
Log in to Azure CLI

Now login to the Container Registry (CR)  (Docker should be running, in Windows Docker desktop).

az acr login --name <registry-name>
For me:
az acr login --name <em><strong>mehzancontainerRegistry</strong></em>
azure-container-registry-6.png
Login Container registry is succeeded.
docker push mehzancontainerregistry.azurecr.io/mezan07/productmicroservice:latest 

and the result is as follow image:

azure-container-registry-7.png
Image: mehzan07/productmicroservice is pushed to Container register
docker rmi mehzancontainerregistry.azurecr.io/mezan07/productmicroservice:latest

List container images

To list the images in your registry, navigate to your registry in the portal and select Repositories, then select the mezan07/productmicroservice repository you created with docker push.

azure-container-registry-8.png
Pushed Repository: mehzan07/Productmicroservice on Azure portal

By selecting the mehzan07/Productmicroservice repository, you see the latest-tagged image under Tags.

Run image from registry

Now, you can pull and run the mehzan07/Productmicroservice:latest container image from your container registry by using docker run:

docker run mehzancontainerregistry.azurecr.io/mezan07/productmicroservice:latest
azure-container-registry-9.png
Running container from mehzancontainerregistry.azurecr.io

Clean up resources

To clean up your resources, navigate to the mehzanRSG  resource group in the portal. Once the resource group is loaded, click on Delete resource group to remove the resource group, the container registry, and the container images stored there.

azure-container-registry-10.png
Clean up resources

Conclusion

In this post I have described how to create an Azure container registry using the Azure portal.  Pulled image from Dockerhub and tagged it and pushed an image to Azure Container registry (ACR).  Finely  pulled the image  and ran the image from the registry.

This post is part of “Azure step by step 

Back to home page

 

Leave a Reply

Your email address will not be published. Required fields are marked *