简体   繁体   中英

Error connecting to azure container registry using system assigned managed identity from a VM

I'm not able to connect to Azure Container registry from a VM with System Assigned Managed Identity Enabled. The MI is assigned acrpush role on the ACR.

I'm following the link enter link description here

az login --identity --> works

az acr login --name myContainerRegistry --> fails with error

An error occurred: DOCKER_COMMAND_ERROR
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied```

Not Sure why it was giving the above error. The docker was in running status(Active), I checked it using service docker status command.

But when I tried the next day again az acr login command, it worked like a charm.

After login I was able to push the image from GitLab Runner VM to ACR using Managed Identity by following the below steps.

The 3rd step to tag the image is important, without tagging we get authentication required error, even when the Managed Identity is assigned acrpush role

1) az login --identity      
2) az acr login --name <mycontainerregistry>
3) docker image tag <image>:version mycontainerregistry.azurecr.io/<image:version>
4) docker push mycontainerregistry.azurecr.io/<image>:<version>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM