How to Create Container Registry on Azure

  • First login into azure portal click on all services > Container Registry.

 

  • Click on Create.

 

  • On the Basics tab provide all required details such as resource group & Instance details (Registry name, location & SKU).Click Next on Networking.

 

  • Now by default connectivity method is public endpoint(all network).
  • Select SKU basic and by default you will find customer managed key will disable.

 

  • Once you will select SKU Premium at first step then you will be able to select pubic or private endpoint and also be able to select customer-managed key at encryption page. 

 

 

  • Click on Next Encryption and by default Customer-Managed key will be disabled if you select SKU “Basic” at first step.

 

  • Once you will select SKU Premium at first step then you will be able to select  customer-managed key. 

  • Now click on Next Tags and provide the tag name for container registry and click on Review + create.

 

  • Once validation passed successfully click on create option.
  • Now go to Container register Home page.

 

  • Now Login 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 name when logging in with the Azure CLI. Don’t use the login server name, which includes a domain suffix like azurecr.io.

az acr login –name <registry-name>

For example: az acr login –name mycontainerregistry

The above command return Login Succeeded once completed.

  • Push image to registry.

To push an image to an Azure Container registry, you must first have an image. If you don’t yet have any local container images, run the following docker pull command to pull an existing public image.

For this example, pull the hello-world image from Microsoft Container Registry.

docker pull mcr.microsoft.com/hello-world

Before push an image to registry you must tag it with the fully qualified name of your registry login server. The login server name is in the format <registry-name>.azurecr.io (must be all lowercase), for example, mycontainerregistry.azurecr.io.

Tag the image using the docker tag command. Replace <login-server> with the login server name of your ACR instance.

docker tag mcr.microsoft.com/hello-world <login-server>/hello-world:v1

For example: docker tag mcr.microsoft.com/hello-world mycontainerregistry.azurecr.io/hello-world:v1

Now use docker push to push the image to the registry instance. Replace <login-server> with the login server name of your registry instance. This example creates the hello-world repository, containing the hello-world:v1 image.

docker push <login-server>/hello-world:v1

After pushing the image to your container registry, remove the hello-world:v1 image from your local Docker environment. (Note that this  docker rmi command does not remove the image from the hello-world repository in your Azure container registry.)

docker rmi <login-server>/hello-world:v1

  • List container images

To list the images in registry navigate to your registry in the portal and select Repositories, then select the hello-world repository you created with docker push.

 

 

By selecting the hello-world repository, you see the v1-tagged image under Tags.

Leave a Reply