Question

Difficulty: HardManage Container Images in Azure Container Registry

You are configuring a CI/CD pipeline script to push container images to an Azure Container Registry (ACR) named `myregistry`. The script runs in a lightweight container context where only the Docker CLI is available for the build and push steps. To authenticate, you have already retrieved a Microsoft Entra ID access token for the registry using the Azure CLI and stored it in a variable named `$TOKEN`.

You need to run the `docker login` command to authenticate the local Docker daemon to the registry using this token.

Which command should you run?

  1. docker login myregistry.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password $TOKENAnswer
  2. B
    docker login myregistry.azurecr.io --username myregistry --password $TOKEN
  3. C
    docker login myregistry.azurecr.io --username <Managed-Identity-Client-ID> --password $TOKEN
  4. D
    az acr login --name myregistry --username 00000000-0000-0000-0000-000000000000 --password $TOKEN

Answer

docker login myregistry.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password $TOKEN
The correct command uses the docker login utility to target the myregistry.azurecr.io login server. When authenticating with an access token (such as a Microsoft Entra ID token), the registry requires the username parameter to be the specific GUID 00000000-0000-0000-0000-000000000000, and the password parameter to contain the token value.

Step-by-Step Solution

1
Identify the registry's login server URL.
The login server URL for an ACR named myregistry is myregistry.azurecr.io.
The docker login command requires the full login server URL rather than just the registry name.
2
Determine the correct username for token-based authentication.
The designated username GUID is 00000000-0000-0000-0000-000000000000.
ACR requires the specific token GUID as the username when authenticating via an access token.
3
Formulate and run the docker login command.
docker login myregistry.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password $TOKEN
This successfully logs the local Docker daemon into the target Azure Container Registry using the retrieved token.

Key Concept

Authenticating with Azure Container Registry using tokens
Rate this question