Is there a way to pull docker images (inside VM) from the ACR without logging in, I am using the same in AWS I assign a role to allow the EC2 to pull from the docker container registry without having to login from the EC2 insistence.
I tried all what I can find on Google but nothing worked for me, it seems this not possible as the only ways to authenticate are list here Authenticate with an Azure container registry
I am also aware that I can enable anonymous access, but I prefer not do that.
thank you in advance.
2
Answers
One way or another you have to use
docker login
oraz acr login
to avoid using passwords you can use a managed identity or service principal to automatically authenticate a virtual machine (VM) with Azure Container Registry (ACR) without manually logging in each time. This approach allows for a more secure and automated way to handle authentication:
Using Managed Identity: Assign a managed identity to your VM and grant it access to the ACR. This managed identity can then be used for authentication, allowing the VM to pull images from the ACR without manual login.
Using Service Principal: Create a service principal and assign it the necessary permissions to access the ACR. You can then configure your VM to use this service principal for authentication.
But in case you do not want to run the commands manually inside the virtual machine you can use a startup script that logs in for you or you can play around with the
dockerconfig
file and mount it to your VM so it takes the credentials from there.Read it here
Pulling Docker
images fromAzure Container Registry
generally requires authentication. Azure primarily relies on authentication through service principals, user credentials and managed identities.If you want to avoid storing credentials on your VM, you can consider using
Managed Identity
by following below steps for Azure resources.system-assigned
managed identity.AcrPull
role to the managed identity associated with your VM.Pull Docker Images: On your VM, install the Azure CLI if it’s not already installed. You can use the following command to log in using the managed identity
Pull Docker Image: After logging in with the managed identity, you should be able to pull images from ACR without explicit credentials.