How to get the list of docker images from Azure private registry How to get the list of docker images from Azure private registry docker docker

How to get the list of docker images from Azure private registry


You can use the container registry cli for azure:

az acr repository list --name <acrName> --output table

https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-azure-cli


It is important to understand how docker lists the images in the registry.Docker CLI provides command to pull/push/delete images from a private Azure Registry like myprivate.azurecr.io after the user authenticates itself using docker login command but the docker CLI does not provide any command to list the images in the private registry.

It is important to understand that the docker image ls only lists the images present on the local machine and not in a registry.There are multiple answers that describe the Docker HTTP API V2 (Refer here) to list the images present in the registry. The HTTP v2 API v2/_catalog and other only work with local registry created on-premise but when user wants to list the images present in the Private Azure Registry one needs to use Azure CLI

What is Local Registry ?

The Registry is a stateless, highly scalable server side application that stores and lets you distribute Docker images. The Registry is open-source, under the permissive Apache license. Local Registry can be created to store and distribute images in house or on-premise.Refer here : https://docs.docker.com/registry/ . One can create a private registry,push and pull image from there using Dokcker HTTP API V2.

Azure CR is a special type and inorder to list the images there is no other option to Azure CLI.

Use Case- List the top three images present in the registryThe command for the same can be

az acr repository show-tags -n <RegistryName> --repository <RepositoryName> --orderby time_desc --output table | select -First 5


As yamenk said, you could use Azure CLI 2.0 to get your registry on azure.

Azure Cli 2.0 works on linux and docker, so I think it could work your linux machine.

Also, you could use Azure Rest APi to get registry on azure.

GET https://management.azure.com/subscriptions/<subscription id>/resourceGroups/<rg>/providers/Microsoft.ContainerRegistry/registries/<registry name>?api-version=2017-10-01

For get token, please refer to this link.

Using API like below:

curl -X "GET" "https://management.azure.com/subscriptions/********/resourceGroups/shuiapp/providers/Microsoft.ContainerRegistry/registries/shuitest?api-version=2017-10-01" \    -H "Authorization: Bearer $token" \    -H "Content-Type: application/json"