Pushing to Azure Container Registery (ACR) fails when following Tutorial

Siegfried Heintze 1,866 Reputation points
2022-12-21T21:57:21.167+00:00

I'm trying to follow this tutorial to push a custom image to the azure container registry.

  1. I execute "docker login $registry.azurecr.io" from a bash script and it says "Error: Cannot perform an interactive login from a non TTY device". However, it seems to work when using an interactive prompt (I get "Login Succeeded"). Is there a way I can do this from a script?
  2. So I abandon my bash script and continue with the interactive powershell prompt and after tagging my image I try "docker push $env:registry.azurecr.io/$env:image:latest" and I get "unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information". I tried that URL and did not find anything helpful except a confirmation that the owner (me) should be able to push.
  3. However, "az acr build -g $rg --image $repo/$image:v1 --registry $registry --file Dockerfile ." works fine from my bash script with no login and I can deploy the resulting image with the command "az webapp create --name $web --resource-group $rg --plan $plan --deployment-container-image-name $registry.azurecr.io/$repo/$image:v1 -s $username -w $password" where $username & $password are the ACR credentials and $repo is the repository called "sample".
  4. Now I'm looking at this other tutorial: container-registry-get-started-docker-cli and it looks like I need to log into my ACR repository (named "demovisualstudiocicdforblazorserver") also... Why did not the first tutorial guide me to log into my ACR repo? OK, I'll try that in my bash script: it is failing! This might be the problem: export password=az acr credential show --resource-group $rg --name $registry --query passwords[0].value --output tsv
    export username=az acr credential show --resource-group $rg --name $registry --query username --output tsv
    az acr login -n $registry -u $username -p $password
    WARNING: Error response from daemon: Get "https://demovisualstudiocicdforblazorserver.azurecr.io/v2/": unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.
    ERROR: Login failed.

Why can I not login? Do I need to login to ACR to push? I don't need to login to ACR (or docker) if I do "acr build".

(5) Also, the second tutorial uses "samples"... I think this is the repository name and the first tutorial does not have a repository name. Is the use of a repository name like "samples" optional?

(6) I'd like to be able to see the docker push command in the first tutorial work for ACR. So far it works only when I'm using dockerhub instead of ACR.

Thanks

Siegfried

Azure Container Registry
Azure Container Registry

An Azure service that provides a registry of Docker and Open Container Initiative images.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Siegfried Heintze 1,866 Reputation points
    2022-12-23T01:11:29.397+00:00

    This works

     echo $DOCKERHUB_PASSWORD | docker login  -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD  
    

    This does not work:

      echo $DOCKERHUB_PASSWORD | docker login  $registry.azurecr.io -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD  
    

    But this works

    docker login  $registry.azurecr.io -u $ACR_username -p $ACR_password  
    

    I wish the tutorials would explain which credentials to use for "docker login".

    Mystery solved!

    Was this answer helpful?

    1 person found this answer helpful.

  2. Siegfried Heintze 1,866 Reputation points
    2022-12-23T16:21:28.577+00:00

    When logging in with docker, be sure to use the ACR credentials and not the docker credentials.

    Was this answer helpful?


  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.