संपादित करें

इसके माध्यम से साझा किया गया


Tutorial - Create an Azure Container Registry (ACR) and build images

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:

  • Create an ACR instance.
  • Use ACR Tasks to build and push container images to ACR.
  • View images in your registry.

Before you begin

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.

Create an Azure Container Registry

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.

  1. Create a resource group using the az group create command.

    az group create --name myResourceGroup --location eastus
    
  2. 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
    

Build and push container images to registry

  • 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/
    

List images in registry

  • 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
    

Next steps

In this tutorial, you created an ACR and pushed images to it to use in an AKS cluster. You learned how to:

  • 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.