Publish your first docker image to Azure Container Registry

May 07, 2021 by Anuraj

Docker ACR Azure

This article will discuss about configuring Azure Container Registry and publishing first your docker image to Azure Container Registry. Azure Container Registry is a managed, private Docker registry service based on the open-source Docker Registry 2.0. Create and maintain Azure container registries to store and manage your private Docker container images and related artifacts.

To get started, first you need to create an Azure Container Registry. First you need to click on new resource on Azure Portal, the search for Container Registry and select the option.

Azure Container Registry

In the next screen, you need to configure the name of the registry, location and SKU - for this article I choose the Basic SKU.

Azure Container Registry

Once you configure all these values, you can click on the Review and Create button. The Networking and Encryption available only on Premium SKU. So you can ignore it now. Once you create the Container Registry. You need to open the Access Keys blade. In the Screen you need to enable the Admin User option. By default it will be disabled.

Access Key - Azure Container Registry

Once you enable it, you will get two passwords, which is required for publishing the images from Docker CLI.

Access Key - Azure Container Registry - Admin User Enabled

Now you have completed the configuration in Azure Portal. Next you need build the image. Here is a nodejs application - I am building a Docker image for this application and publishing it to Azure Container Registry. You can build it using docker build command - docker build -t . You need to tag the image with your container server name. In this example - Once you build it, you can use the docker images command or you use Docker Desktop UI to check the image is created.

Docker Images

Next you need to login to the container registry. You can use Azure CLI or Docker CLI to do this. In this example I am using Docker CLI. First you need to execute the command docker login - instead of use your registry URL. Next it will prompt for your credentials you need to provide the username and password from the Access Keys section. Once it is completed you are ready to publish the image to your container registry. For that you can execute the following command - docker push - again you need to use the image with your ACR name.

Docker Push Command

Once it is completed, you can open the Repositories Blade in Azure Portal and verify whether the Image is available or not.

ACR - Published Images

Now you successfully uploaded an image from your machine to Azure Container Registry. Azure Container Registry plays a key role when you want deploy your containers to Azure Container Instances and Azure App Services - you can choose the Container Registry and deploy the containers without much effort.

Happy Programming :)

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub