How to List All Images in Docker Registry V2

  1. Get a Complete List of Images on Docker Registry V2
  2. List All Repositories and Images
  3. List All Tags of a Repository
  4. Query an API With Credentials
How to List All Images in Docker Registry V2

A few iterations back, Docker Registry upgraded from version 1 to version 2. Particularly new, some commands need to be included or documented adequately on their official documentation website.

One example is getting the list of images in the Docker Registry.

This article will discuss getting the list of images in Docker Registry V2.

Get a Complete List of Images on Docker Registry V2

Before we start, pull the latest version of Docker Registry in DockerHub by running the command below.

docker pull distribution/registry:master

In Docker Registry version 1, we can get a list of all images by performing an API GET call to the base URL of http://myregistry:5000/v1/search?. Though not implied in the documentation, we can also perform a similar approach by calling a GET request to an updated and different base URL.

List All Repositories and Images

When Docker updated the Docker Registry to version 2, they also updated all their API base URLs. So now, instead of calling the v1 base URL, we can use the URL below.

curl -X GET https://myregistry:5000/v2/_catalog

The default result only shows one hundred (100) image records, but if you need to show more, you can paginate the result by appending a query parameter.

curl -X GET https://myregistry:5000/v2/_catalog?n=<count>

List All Tags of a Repository

If we need to list all of the tags of a repository, we can use a different endpoint below.

curl -X GET https://myregistry:5000/v2/<name>/tags/list

We can replace the name value with the name of the repository from which we want to query tags.

Query an API With Credentials

If the registry needs authentication, we must specify our credentials in the curl command by adding a -u flag.

curl -X GET -u <username>:<password> https://myregistry:5000/v2/_catalog
curl -X GET -u <username>:<password> https://myregistry:5000/v2/<name>/tags/list

If our registry uses a self-signed certificate instead of credentials, we can make an insecure request by adding a -k and --insecure flags. However, this is considered a security risk so use this at your own risk.

Docker Registry v2 API offers more endpoints that cater to more requests. We can find the complete endpoints in this link.

Marion Paul Kenneth Mendoza avatar Marion Paul Kenneth Mendoza avatar

Marion specializes in anything Microsoft-related and always tries to work and apply code in an IT infrastructure.

LinkedIn

Related Article - Docker Registry