Following our previous blog post about Azure Container Registry (ACR) today we will show how to log in to an existing registry.
To set up a new ACR using Bicep, please visit this blog post.
Azure Container Registry
The Azure Container Registry is a secure, private registry for storing and managing your container images. It can be used to store images for both public and private containers, and you can use it to deploy both Linux- and Windows-based containers. The registry is fully integrated with Azure, making it easy to manage your images from a single location.
To login to ACR, we need to first retrieve the Access Keys of the registry from the Azure portal. you can look at access keys as username and password.
To access the Access Keys, open your ACR from the Azure portal and click on Access Keys.
The Access Keys page contains all the details you need to login to ACR, which include Registry name, Login Server, username and password.
Login to ACR
To login to ACR, you need a Docker client running on Windows, Linux or macOS.
Below I have three Docker commands that push a Docker image to an ACR registry called myacr.
- The first Docker command tags an existing image called myimage to my ACR registry.
- The 2nd command login to ACR and prompts for a username and password.
- The last command pushes the image to ACR.
docker tag myimage myacr.azurecr.io/myimage docker login myacr.azurecr.io docker push myacr.azurecr.io/myimage
To pull an image from ACR we use the following two commands.
docker login myacr.azurecr.io docker pull myacr.azurecr.io/myimage