Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to: AKS on Azure Local 22H2, AKS on Windows Server
An Azure Container Registry is a private registry for container images. A private container registry lets you securely build and deploy your applications and custom code.
In this tutorial, part two of seven, you deploy an Azure Container Registry instance and push a container image to it for use in AKS. You'll learn how to:
In later tutorials, this Azure Container Registry instance is integrated with a Kubernetes cluster, and an application is deployed from the image.
The previous tutorial described how to create a container image for a simple Azure Voting application. If you have not created the Azure Voting app image, return to Tutorial 1 – Create container images.
This tutorial requires that you run the Azure CLI version 2.0.53 or later. Run az --version
to find the version. If you need to install or upgrade, see Install Azure CLI.
To create an Azure Container Registry instance, you first need a resource group. An Azure resource group is a logical container into which Azure resources are deployed and managed.
Create a resource group with the az group create command. In the following example, a resource group named myResourceGroup is created in the eastus region:
az group create --name myResourceGroup --location eastus
Create an Azure Container Registry instance with the az acr create command and provide your own registry name. The registry name must be unique within Azure, and contain 5-50 alphanumeric characters. In the rest of this tutorial, <acrName>
is used as a placeholder for the container registry name. Provide your own unique registry name. The Basic SKU is a cost-optimized entry point for development purposes that provides a balance of storage and throughput.
az acr create --resource-group myResourceGroup --name <acrName> --sku Basic
To use the ACR instance, you must first log in. Use the az acr login command and provide the unique name given to the container registry in the previous step:
az acr login --name <acrName>
The command returns a Login Succeeded message when completed.
To see a list of your current local images, use the docker images command:
docker images
This command's output shows a list of your current local images:
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/azuredocs/azure-vote-front v1 84b41c268ad9 7 minutes ago 944MB
mcr.microsoft.com/oss/bitnami/redis 6.0.8 3a54a920bb6c 2 days ago 103MB
tiangolo/uwsgi-nginx-flask python3.6 a16ce562e863 6 weeks ago 944MB
To use the azure-vote-front container image with Azure Container Registry, make sure you tag the image with the login server address of your registry. This tag is used for routing when pushing container images to an image registry.
To get the login server address, use the az acr list command and query for the loginServer as follows:
az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table
Now, tag your local azure-vote-front image with the acrLoginServer address of the container registry. To indicate the image version, add :v1 to the end of the image name:
docker tag mcr.microsoft.com/azuredocs/azure-vote-front:v1 <acrLoginServer>/azure-vote-front:v1
To verify the tags are applied, run docker images again:
docker images
An image is tagged with the Azure Container Registry instance address and a version number:
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/azuredocs/azure-vote-front v1 84b41c268ad9 16 minutes ago 944MB
mycontainerregistry.azurecr.io/azure-vote-front v1 84b41c268ad9 16 minutes ago 944MB
mcr.microsoft.com/oss/bitnami/redis 6.0.8 3a54a920bb6c 2 days ago 103MB
tiangolo/uwsgi-nginx-flask python3.6 a16ce562e863 6 weeks ago 944MB
With your image built and tagged, push the azure-vote-front image to your Azure Container Registry instance. Use docker push and provide your own acrLoginServer
address for the image name as follows:
docker push <acrLoginServer>/azure-vote-front:v1
It might take a few minutes to complete the image push to Azure Container Registry.
To return a list of images that were pushed to your Azure Container Registry instance, use the az acr repository list command. Provide your own <acrName>
as follows:
az acr repository list --name <acrName> --output table
The following example output lists the azure-vote-front image as available in the registry:
Result
----------------
azure-vote-front
To see the tags for a specific image, use the az acr repository show-tags command:
az acr repository show-tags --name <acrName> --repository azure-vote-front --output table
The following example output shows the v1 image tagged in a previous step:
Result
--------
v1
You now have a container image that is stored in a private Azure Container Registry instance. This image is deployed from Azure Container Registry to a Kubernetes cluster in the next tutorial.
In this tutorial, you created an Azure Container Registry and pushed an image for use in a Kubernetes cluster. You learned how to:
Advance to the next tutorial to learn how to deploy a Kubernetes cluster in Azure.
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now