dockerversion

How to list available repo versions using Docker


Is there a way to let Docker list all the available image versions that can be downloaded?

Let's say I want to get the latest version of Apache, then I could type this:

docker pull httpd:latest

Now, if I am interested in a particular version, I could type this:

docker pull httpd:2.4.34

In order to be able to do that though, I need to know that there is a version 2.4.34 available. Now, is there a way to list available versions? I am looking for something similar to this:

docker list httpd versions

and I would like to have a response similar to this:

2.4.34
2.4.32
2.4.29
2.2.34
...

Solution

  • There is an API endpoint for this action which is explained here:

    https://docs.docker.com/registry/spec/api/#listing-image-tags
    

    The endpoint itself is the following:

    /v1/repositories/(namespace)/(repository)/tags
    

    So you can run the following command in order to access it:

    curl -u <username>:<password> https://registry-1.docker.io/v1/repositories/<username>/<image_name>/tags