How to authenticate docker to Azure Container registry
- Make sure your account has been added with at least read access to the acr (Azure Container Registry).
- Also if your account is a guest in the Azure Active Directory. Make sure you have completed your registration you'll get an email. A common error if you have not completed registration is Unable to find Subscription.
- Download the Azure cli and install it. You can download it for windows at https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest. You can find install instructions for other OS's here https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
- Now login to azure with the account that was setup in step 1. Use the command below and follow the screen instructions.
- az login
- If you have multiple subscriptions you'll need to select the subscription the acr is in.
- az account set --subscription <subscription guid>
- This step is optional but is usually needed. Install 'ACR Docker Credential Helper' full instructions can be found on github. Below are the commands to install it.
- Windows Powershell
- iex ([System.Text.Encoding]::UTF8.GetString((Invoke-WebRequest -Uri https://aka.ms/acr/installaad/win).Content))
- Linux and OS X
- curl -L https://aka.ms/acr/installaad/bash | /bin/bash
- Now login to your acr. <name> will be the part before .azurecr.io in the url to your acr.
- az acr login --name <name>
- Now you should be able to pull and push to your acr.
Note: The login to the acr does not last. It seams to only be valid for around 5 to 10 minutes. But its really easy to authenticate to again just re run step 6 above.
Comments
Post a Comment