Question

Difficulty: EasyManage Container Images in Azure Container Registry

A developer needs to push a locally built container image to an Azure Container Registry (ACR) named contosoacr. The developer has already logged into their Azure account on their workstation using the Azure CLI command az login. However, when they attempt to push the image, they receive an authentication error from the Docker daemon.

Which of the following Azure CLI commands should the developer run to authenticate the local Docker daemon to the registry?

  1. az acr login --name contosoacrAnswer
  2. B
    docker login contosoacr.azurecr.io
  3. C
    az login --registry contosoacr
  4. D
    az acr login --name contosoacr --identity

Answer

Run the command az acr login --name contosoacr to authenticate the local Docker daemon to the registry.
The command az acr login --name contosoacr uses the active Azure CLI session to fetch a token and configure the local Docker daemon. This allows the subsequent docker push command to authenticate successfully against the private container registry.

Step-by-Step Solution

1
Ensure the developer is signed in to Azure using the Azure CLI command az login.
The Azure CLI has an active authentication session on the workstation.
This provides the credentials necessary to access Azure resources, including the registry.
2
Run the command az acr login --name contosoacr.
The local Docker configuration is updated with credentials to access the registry.
This helper command bridges Azure CLI authentication with the Docker daemon configuration.
3
Execute the docker push command.
The container image is successfully pushed to the Azure Container Registry.
The Docker daemon is now authenticated and authorized to perform the push operation.

Key Concept

Authenticating a local developer workstation to Azure Container Registry using the Azure CLI.
Rate this question