Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Task 03 - Pushing the Container Image to Azure Container Registry

Introduction

In this task, you will tag and deploy your container image to Azure Container Registry

Description

In this task, you will:

  • Run a CLI command to create the ACR resource in your Azure Resource Group
  • Tag and Push the container image to ACR

Success Criteria

  • Successfully create a new ACR resource in your Resource Group
  • Successfully Tag and Push the container image to your ACR resource in Azure.

Solution

Expand this section to view the solution
  1. From the command terminal, make sure you are logged in to your Azure account using the Azure CLI. If you are not logged in, use the following command to log in:

     az login
    

    If necessary, select the appropriate subscription using the following command from the list of subscriptions shown in the output of the previous command.

  2. To provide an Azure Container Registry (ACR) resource to hosting your image in Azure, use the following command to create an ACR resource. Make sure to replace the [YOUR_GLOBALLY_UNIQUE_ACR_NAME] token with your own globally unique value, such as tailspinacr24601, before running the command.

      az acr create \
       --resource-group rg-tailspin \
       --name [YOUR_GLOBALLY_UNIQUE_ACR_NAME] \
       --sku Basic
    

    IMPORTANT: The above command assumes you are using the rg-tailspin resource group you created in Exercise 0. If you used a different name, please replace it in the az command above.

  3. Login to the ACR resource from your terminal, ensuring you replace the [YOUR_GLOBALLY_UNIQUE_ACR_NAME] token with your own globally unique value for the ACR resource.

     az acr login --name [YOUR_GLOBALLY_UNIQUE_ACR_NAME]
    
  4. Tag the container image by running the following command, ensuring you replace the [YOUR_GLOBALLY_UNIQUE_ACR_NAME] token with your own globally unique value for the ACR resource.

     docker tag aks-demo:1.0 [YOUR_GLOBALLY_UNIQUE_ACR_NAME].azurecr.io/aks-demo:1.0
    

    You can retrieve the Login Server URI from the portal in the ACR resource under Settings|Access Keys

    ACR Login Server

  5. Push the container image to ACR by running the following command, ensuring you replace the [YOUR_GLOBALLY_UNIQUE_ACR_NAME] token with your own globally unique value for the ACR resource.

     docker push [YOUR_GLOBALLY_UNIQUE_ACR_NAME].azurecr.io/aks-demo:1.0
    
  6. After a minute, you can verify the deployment of the container image to ACR by selecting the Repositories item under Services in the left navigation menu in the Azure Portal for the ACR resource. You should see the aks-demo repository with the 1.0 tag for the image you just pushed.

    ACR Repositories