Quickstart: Create a private container registry using the Azure portal

An Azure container registry is a private Docker registry in Azure where you can store and manage your private Docker container images. In this quickstart, you create a container registry 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, this quickstart requires 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 Mac, Windows, or Linux system.

Sign in to Azure

Sign in to the Azure portal at https://portal.azure.com.

Create a container registry

Select Create a resource > Containers > Container Registry.

Creating a container registry in the Azure portal

Enter values for Registry name and Resource group. The registry name must be unique within Azure, and contain 5-50 alphanumeric characters. For this quickstart create a new resource group in the West US location named myResourceGroup, and for SKU, select 'Basic'. Select Create to deploy the ACR instance.

Create container registry in the Azure portal

In this quickstart you create a Basic registry, which is a cost-optimized option for developers learning about Azure Container Registry. For details on available service tiers, see Container registry SKUs.

When the Deployment succeeded message appears, select the container registry in the portal.

Container registry Overview in the Azure portal

Take note of the value of the Login server. You use this value in the following steps while working with your registry with the Azure CLI and Docker.

Log in to registry

Before pushing and pulling container images, you must log in to the ACR instance. Open a command shell in your operating system, and use the az acr login command in the Azure CLI.

az acr login --name <acrName>

The command returns 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 image from Docker Hub. For this example, pull the hello-world image.

docker pull hello-world

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

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

docker tag hello-world <acrLoginServer>/hello-world:v1

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

docker push <acrLoginServer>/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 <acrLoginServer>/hello-world:v1

List container images

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

In this example, we select the busybox repository, and we can see the v1-tagged image under TAGS.

List container images in the Azure portal

Run image from registry

Now, you can pull and run the hello-world:v1 container image from your container registry by using docker run:

docker run <acrLoginServer>/hello-world:v1  

Example output:

Unable to find image 'mycontainerregistry007.azurecr.io/hello-world:v1' locally
v1: Pulling from hello-world
Digest: sha256:662dd8e65ef7ccf13f417962c2f77567d3b132f12c95909de6c85ac3c326a345
Status: Downloaded newer image for mycontainerregistry007.azurecr.io/hello-world:v1

Hello from Docker!
This message shows that your installation appears to be working correctly.

[...]

Clean up resources

To clean up your resources, navigate to the myResourceGroup 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.

Delete resource group in the Azure portal

Next steps

In this quickstart, you created an Azure Container Registry with the Azure portal, pushed a container image, and pulled and ran the image from the registry. Continue to the Azure Container Registry tutorials for a deeper look at ACR.