Login to Azure Container Registry on Windows

Before pushing and pulling container images, you need to sign into the container registry.

Requirements

  • Install AZ CLI on Windows (Server or Desktop)
  • Install Microsoft Edge browser on Windows Server
  • Install Docker CE runtime on Windows Server
  • The login server name for the target container registry

Process

Now you need to sign into Azure, so open Terminal and sign into Azure

az login

You need to make sure you are working in the correct Azure subscription.

az account show
az account set --subscription [subscription_name]

(optional) Retrieve the login server name of your ACR or copy it direct from the Azure portal.

az acr list --resource-group [YourResourceGroupName] --query "[].{acrLoginServer:loginServer}" --output table

Using the ACR login server you can log into the container registry.

az acr login --name [acr_login_server]

Login to ACR using the access token method By following these steps, you should be able to log into your ACR using Docker without having to input your credentials manually. The access token is used in place of your password. To use the access token method for logging into Azure Container Registry (ACR) with Docker, follow these steps in your PowerShell session:

  • Get the Access Token Use the Azure CLI to get an access token for your ACR. Replace <acrName> with the name of your ACR. This command logs you into the ACR and exposes an access token, then converts the JSON output into a PowerShell object.
$loginResult = az acr login --name <acrName> --expose-token --output json | ConvertFrom-Json
  • Capture the Access Token as a Variable Extract the access token from the previous command’s output and store it in a variable.
$accessToken = $loginResult.accessToken
  • Login to Docker with the Access Token Use the access token to log in to Docker. The username is a fixed value (00000000-0000-0000-0000-000000000000) when using an access token.
docker login <acrName>.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password $accessToken
Last modified July 21, 2024: update (e2ae86c)