There is no Docker command that can be used to retrieve and list all the tags of a Docker image on a remote Docker registry. This would be useful, for example, to list all the tags of a given Docker image from the Docker Hub registry.
Docker Hub enables the retrieval of the list of all tags of a given repository (or image) using the HTTP GET command from this URL: https://registry.hub.docker.com/v1/repositories/your-repository-name/tags
. This information will be in the JSON format. A JSON parser like jq can be used to retrieve the tag names from this JSON.
Putting all this together, we can create a command to list all the tags of a repository named repo1/foobar2
from Docker Hub:
$ wget -q https://registry.hub.docker.com/v1/repositories/repo1/foobar2/tags -O - | jq -r .[].name
If you do not have jq
, it can be installed easily:
$ sudo apt install jq
The above command can be easily turned into a shell script that accepts a repository (or image) name as input and list its tags from the Docker Hub.
Tried with: Docker 18.09.6 and Ubuntu 18.04