title | description | ms.topic | ms.date | author | ms.author | ms.custom |
---|---|---|---|---|---|---|
Kubernetes on Azure tutorial - Create an Azure Container Registry and build images |
In this Azure Kubernetes Service (AKS) tutorial, you create an Azure Container Registry instance and upload sample application container images. |
tutorial |
11/28/2023 |
schaffererin |
schaffererin |
mvc, devx-track-azurecli, devx-track-azurepowershell |
Azure Container Registry (ACR) is a private registry for container images. A private container registry allows you to securely build and deploy your applications and custom code.
In this tutorial, part two of seven, you deploy an ACR instance and push a container image to it. You learn how to:
[!div class="checklist"]
- Create an ACR instance.
- Use ACR Tasks to build and push container images to ACR.
- View images in your registry.
In the previous tutorial, you used Docker to create a container image for a simple Azure Store Front application. If you haven't created the Azure Store Front app image, return to Tutorial 1 - Prepare an application for AKS.
This tutorial requires 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.
This tutorial requires Azure PowerShell version 5.9.0 or later. Run Get-InstalledModule -Name Az
to find the version. If you need to install or upgrade, see Install Azure PowerShell.
Before creating an ACR instance, you need a resource group. An Azure resource group is a logical container into which you deploy and manage Azure resources.
Important
This tutorial uses myResourceGroup as a placeholder for the resource group name. If you want to use a different name, replace myResourceGroup with your own resource group name.
-
Create a resource group using the
az group create
command.az group create --name myResourceGroup --location eastus
-
Create an ACR instance using the
az acr create
command and provide your own unique registry name. The registry name must be unique within Azure and contain 5-50 alphanumeric characters. The rest of this tutorial uses an environment variable,$ACRNAME
, as a placeholder for the container registry name. You can set this environment variable to your unique ACR name to use in future commands. 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
-
Create a resource group using the
New-AzResourceGroup
cmdlet.New-AzResourceGroup -Name myResourceGroup -Location eastus
-
Create an ACR instance using the
New-AzContainerRegistry
cmdlet and provide your own unique registry name. The registry name must be unique within Azure and contain 5-50 alphanumeric characters. The rest of this tutorial uses an environment variable,$ACRNAME
, as a placeholder for the container registry name. You can set this environment variable to your unique ACR name to use in future commands. The Basic SKU is a cost-optimized entry point for development purposes that provides a balance of storage and throughput.New-AzContainerRegistry -ResourceGroupName myResourceGroup -Name $ACRNAME -Location eastus -Sku Basic
-
Build and push the images to your ACR using the Azure CLI
az acr build
command.[!NOTE] For this step, there isn't an equivalent Azure PowerShell cmdlet that performs this task.
In the following example, we don't build the
rabbitmq
image. This image is available from the Docker Hub public repository and doesn't need to be built or pushed to your ACR instance.az acr build --registry $ACRNAME --image aks-store-demo/product-service:latest ./src/product-service/ az acr build --registry $ACRNAME --image aks-store-demo/order-service:latest ./src/order-service/ az acr build --registry $ACRNAME --image aks-store-demo/store-front:latest ./src/store-front/
-
View the images in your ACR instance using the
az acr repository list
command.az acr repository list --name $ACRNAME --output table
The following example output lists the available images in your registry:
Result ---------------- aks-store-demo/product-service aks-store-demo/order-service aks-store-demo/store-front
-
View the images in your ACR instance using the
Get-AzContainerRegistryRepository
cmdlet.Get-AzContainerRegistryRepository -RegistryName $ACRNAME
The following example output lists the available images in your registry:
aks-store-demo/productservice aks-store-demo/orderservice aks-store-demo/storefront
In this tutorial, you created an ACR and pushed images to it to use in an AKS cluster. You learned how to:
[!div class="checklist"]
- Create an ACR instance.
- Use ACR Tasks to build and push container images to ACR.
- View images in your registry.
In the next tutorial, you learn how to deploy a Kubernetes cluster in Azure.
[!div class="nextstepaction"] Deploy Kubernetes cluster