Published on

Azure ACR 101

316 words2 min read
Authors

Azure ACR 101

Azure Container Registry (ACR) is a managed Docker registry service provided by Azure for storing and managing your private Docker container images and other artifacts. It's based on the open-source Docker Registry 2.0.

In this blog, we will guide you through the process of building, pushing, and pulling an image using Azure ACR.

Prerequisites

Login to Azure

First, you need to login to your Azure account and set your subscription.

az login
az account set --subscription "your-subscription-id"

Create a resource group and a registry

Create a resource group and a registry.

az group create --name myResourceGroup --location eastus
az acr create --resource-group myResourceGroup --name myRegistry --sku Basic

Build image

Now, you can build an image and push it to the registry.

az acr build --image sample/hello-world:v1 --registry myRegistry --file Dockerfile .

NOTE: You can also use the docker build -t command to build and tag the image.

docker build -t myRegistry.azurecr.io/sample/hello-world:v1 .

Push image

Push the image to the registry.

az acr push --image sample/hello-world:v1 --registry myRegistry

or you can use the docker push command to push the image.

docker push myRegistry.azurecr.io/sample/hello-world:v1

Pull image from registry

Finally, you can pull the image from the registry to use it.

docker pull myRegistry.azurecr.io/sample/hello-world:v1

Conclusion

That's it! You have successfully built, pushed, and pulled an image using Azure ACR. We hope this guide helps you understand the process better and encourages you to explore more with Azure ACR.