Push docker image into azure container registries repository using powershell

Viewed 1185

I am trying to push docker image into azure container registries repository using power-shell command as follows:-

docker push containerregone.azurecr.io/azure-vote-front:V1

it gives me following error

unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.

I have tried to find help related to this using following documentation

https://docs.microsoft.com/en-us/azure/container-registry/container-registry-faq https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication

but it gives Azure CLI commands.

I have also tried to do this using following link

https://stackoverflow.com/questions/50817945/what-is-the-powershell-equivalent-to-az-acr-login#:~:text=There%20is%20no%20single%20powershell,docker%20login%20to%20log%20in.

but they are using docker login. i don't have docker login.

My Question :-

  1. How can we accomplish this using power-shell without docker login?
2 Answers

I'm afraid you cannot accomplish that using PowerShell without the command docker login. Let's take a look at the command for the ACR credential.

When you use the CLI command az acr login with the ACR directly without a docker daemon running, then you will get the error similar with this:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

It means the CLI command az acr login depends on the docker server. When you run the CLI command az acr login --expose-token as the document shows, it just exposes the access token of the ACR without login for docker. You also need to log in yourself for docker. You can see the details here.

For the PowerShell for ACR, the only one is to get the ACR credential: Get-AzContainerRegistryCredential. But it gets the passwords for you only. It's not the access token, nor will log in for you too.

So, if you want to use PowerShell command to get the ACR credential, then you also need to log in yourself with the docker command.

Before push or pull, to azure, you need to login first by az-cli

az login
az acr login -n your-registry

or by docker

 docker login your-registry.azurecr.io
Related