How can I list all tags for a Docker image on a remote registry?
Asked Answered
M

29

423

How can I list all tags of a Docker image on a remote Docker registry using the CLI (preferred) or curl?

Preferably without pulling all versions from the remote registry. I just want to list the tags.

Masker answered 4/2, 2015 at 11:22 Comment(4)
similar to #24482064Concertina
I opened a ticket asking for this feature in docker(1) github.com/docker/for-linux/issues/455Amends
Possible duplicate of How can I find a Docker image with a specific tag in Docker registry on the Docker command line?Bolero
while a massively newer answer I would urge you to evaluate and potentially choose this one for the newer solution with podman https://mcmap.net/q/80902/-how-can-i-list-all-tags-for-a-docker-image-on-a-remote-registryPlacebo
A
275

Update: Docker has deprecated the Docker Hub v1 API. To fetch tags using the v2 API, use e.g.

wget -q -O - "https://hub.docker.com/v2/namespaces/library/repositories/debian/tags?page_size=100" | grep -o '"name": *"[^"]*' | grep -o '[^"]*$'

Note: The results will be limited to the newest 100 tags. To get the next 100 tags, set the URL to https://.../tags?page_size=100&page=2 etc.

For images other than Docker Official Images, replace library with the name of the user/organization.

The URL https://hub.docker.com/v2/repositories/{namespace}/{repository}/tags also works at the moment, however it is unclear from the API specification whether it is legal.

(If you have jq installed, you can replace the kludgy grep commands with jq -r '.results[].name'.)


Original answer (v1 API, no long supported):

I got the answer from here . Thanks a lot! :)

Just one-line-script:(find all the tags of debian)

wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O -  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}'

UPDATE Thanks for @degelf's advice. Here is the shell script.

#!/bin/bash

if [ $# -lt 1 ]
then
cat << HELP

dockertags  --  list all tags for a Docker image on a remote registry.

EXAMPLE: 
    - list all tags for ubuntu:
       dockertags ubuntu

    - list all php tags containing apache:
       dockertags php apache

HELP
fi

image="$1"
tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O -  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}'`

if [ -n "$2" ]
then
    tags=` echo "${tags}" | grep "$2" `
fi

echo "${tags}"

You can just create a new file name, dockertags, under /usr/local/bin (or add a PATH env to your .bashrc/.zshrc), and put that code in it. Then add the executable permissions(chmod +x dockertags).

Usage:

dockertags ubuntu ---> list all tags of ubuntu

dockertags php apache ---> list all php tags php containing 'apache'

Alchemize answered 12/9, 2016 at 16:0 Comment(10)
You can wrap the whole thing in echo [backtick]...[backtick] to condense it into one line. And/or replace "debian" with $1 and put it in a script called "dockertags" under /usr/local/bin. Then before the closing backtick you can add |grep $2. Then chmod +x it, and then you can go "dockertags php apache" to see all php tags containing apache.Shape
wget -q https://registry.hub.docker.com/v1/repositories/circleci/ruby/tags -O - | jq -r '.[].name' if you have jq installedBrantbrantford
I've posted an updated answer for the V2 API.Amora
sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' is much more cleanly written tr -d '[]" 'Hett
I modified to use the second positional argument as username:password so that I could switch out wget for curl and use userauth="-u ${2}" allowing me to ${userauth} (if it's blank no u toggle or params). This might help anyone using private repo'sAlert
what about wrapping this up into some alpine docker image? :)Wearing
How do we deal with non-docker hub images? e.g. the MS.NET core repo, i.e. mcr.microsoft.com/dotnet/core/aspnetFrederico
For images under a user account use URL: registry.hub.docker.com/v1/repositories/USERNAME/IMAGENAME/tagsOutwit
Add a | tail -1 to the wget-jq above to get the latest tag (as in the latest tag result, not necessarily the latest tag).Skricki
In 2023 it looks like v1 is gone and https://registry.hub.docker.com/v2/repositories/library/<image name>/tags should be used.Appalling
V
140

As of Docker Registry V2, a simple GET suffice:

GET /v2/<name>/tags/list

See docs for more.

p.s. If your image registry requires authentication and you are getting an error message with the text "unauthorized", then there is a solution further down on this page here.

Vadnee answered 14/9, 2016 at 8:12 Comment(3)
Based on the info in the Tags subsection in the docs, this GET seems to require authorization, so the v1 API + sed appears to be actually simpler to use for a quick check...Albuminate
If you're getting an "unauthorized" error, see my alternate answer. No offense to the person who posted the original answer. I had to take additional steps to get the answer above to work and wanted to help others.Amora
For those who need it - if you saved your image as a/b/c:1, <name> will be a/b/c, so you can use curl to GET /v2/a/b/c/tags/list.Magazine
A
58

If you want to use the docker registry v2 API, it lists tags by pages. To list all the tags of an image, you may would like to add a large page_size parameter to the url, e.g.

curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/centos/tags?page_size=1024'|jq '."results"[]["name"]'
Attalie answered 7/5, 2017 at 10:8 Comment(5)
Docker Hub appears to limit page_size to a effective maximum of 100.Pentalpha
@Pentalpha Oh really? I haven't encountered an image with that many pages. Does a url like https://registry.hub.docker.com/v2/repositories/library/centos/tags/?page=101 work?Attalie
the java image is a good example. Yes, you can do things like registry.hub.docker.com/v2/repositories/library/java/tags/…. See the next and previous links in the result for examples.Pentalpha
That jq expression wasn't working for me. I used jq '.results[].name' insteadComplaint
@Pentalpha is correct, the page_size is 100 (at least for non-authenticated requests) - you only get 100 results even if you request more. But it is very helpful that the tags are returned in reverse chronological order (newest first). So if you're looking for the latest tag, you likely only need the first page.Contract
A
39

The Docker Registry API V2 requires an OAuth bearer token with the appropriate claims. In my opinion, the official documentation is rather vague on the topic. So that others don't go through the same pain I did, I offer the below docker_tags function.

The most recent version of docker_tags can be found in my GitHub Gist: "List Docker Image Tags using bash". Editor's note: The versions have diverged.

The docker_tags function has a dependency on jq. If you're playing with JSON, you likely already have it.

#!/usr/bin/env bash
set -eu -o pipefail
docker_tags() {
    item="$1"
    case "$item" in
        */*) :;; # namespace/repository syntax, leave as is
        *) item="library/$item";; # bare repository name (docker official image); must convert to namespace/repository syntax
    esac
    authUrl="https://auth.docker.io/token?service=registry.docker.io&scope=repository:$item:pull"
    token="$(curl -fsSL "$authUrl" | jq --raw-output '.token')"
    tagsUrl="https://registry-1.docker.io/v2/$item/tags/list"
    curl -fsSL -H "Accept: application/json" -H "Authorization: Bearer $token" "$tagsUrl" | jq --raw-output '.tags[]'
}
docker_tags "$@"

Example:

$ docker_tags "alpine"
2.6
2.7
20190228
20190408
...
3
3.1
3.10
3.10.0
3.10.1
...
3.9.5
3.9.6
edge
latest

Admittedly, docker_tags makes several assumptions. Specifically, the OAuth request parameters are mostly hard coded. A more ambitious implementation would make an unauthenticated request to the registry and derive the OAuth parameters from the unauthenticated response.

Amora answered 19/8, 2018 at 21:8 Comment(8)
There's no need for arr=("$@"). Just write docker-tags() { for item; do ....Hett
Thank you for this. Getting that token was driving me nuts.Ca
@WilliamPursell can you post a link to the documentation for whatever enables that magic?Irradiance
@Irradiance pubs.opengroup.org/onlinepubs/9699919799/utilities/…Hett
@WilliamPursell Omitting: in word... shall be equivalent to: in "$@" thanks! Sadly, that doesn't seem to be the case in zsh. 😕Irradiance
I got authorization error using this script. However, an improved version of the script works perfectly, added as a comment: gist.github.com/robv8r/…Unprofessional
@RobV8R: I took the liberty of making some significant changes to your script. If you don't like them, please let me know and I'll revert them and move my version to a separate answer (I just think it's better not to have multiple similar answers). If you do like it, consider updating your Gist and removing my "Editor's note".Teniacide
@tom, thanks for the contribution. I appreciate the update. I realize it's been a while since you made the changes, but I wanted to say "Thank you."Amora
E
37

You can list all the tags with skopeo and jq for json parsing through cli.

skopeo --override-os linux inspect docker://httpd | jq '.RepoTags'
[
  "2-alpine",
  "2.2-alpine",
  "2.2.29",
  "2.2.31-alpine",
  "2.2.31",
  "2.2.32-alpine",
  "2.2.32",
  "2.2.34-alpine",
  "2.2.34",
  "2.2",
  "2.4-alpine",
  "2.4.10",
  "2.4.12",
  "2.4.16",
  "2.4.17",
  "2.4.18",
  "2.4.20",
  "2.4.23-alpine",
  "2.4.23",
  "2.4.25-alpine",
  "2.4.25",
  "2.4.27-alpine",
  "2.4.27",
  "2.4.28-alpine",
  "2.4.28",
  "2.4.29-alpine",
  "2.4.29",
  "2.4.32-alpine",
  "2.4.32",
  "2.4.33-alpine",
  "2.4.33",
  "2.4.34-alpine",
  "2.4.34",
  "2.4.35-alpine",
  "2.4.35",
  "2.4.37-alpine",
  "2.4.37",
  "2.4.38-alpine",
  "2.4.38",
  "2.4.39-alpine",
  "2.4.39",
  "2.4.41-alpine",
  "2.4.41",
  "2.4.43-alpine",
  "2.4.43",
  "2.4",
  "2",
  "alpine",
  "latest"
]

For external registries:

skopeo --override-os linux inspect --creds username:password docker://<registry-url>/<repo>/<image> | jq '.RepoTags'

Note: --override-os linux is only needed if you are not running on a linux host. For example, you'll have better results with it if you are on MacOS.

Entomostracan answered 10/5, 2020 at 0:6 Comment(3)
I see skopeo also has a list-tags command. Together with jq --raw-output you can get a plain list of tags: skopeo --override-os linux list-tags docker://httpd | jq --raw-output .Tags[].Akan
This is the easiest and clean way! Love skopeo!Jesicajeske
I had an IBM repo which doesn't tag latest so I used this to get the info: skopeo --override-os linux inspect docker://icr.io/cpopen/icp4a-content-operator@sha256:9005d19acc265d8e0481d133115d5f1eb8edfcae5cc22a8a774b54f969cda1ab | jq '.RepoTags'Marlite
R
25

If the JSON parsing tool, jq is available

wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O - | \
    jq -r '.[].name'
Ruckman answered 18/3, 2017 at 19:55 Comment(0)
M
21

I've managed to get it working using curl:

curl -u <username>:<password> https://myrepo.example/v1/repositories/<username>/<image_name>/tags

Note that image_name should not contain user details etc. For example if you're pushing image named myrepo.example/username/x then image_name should be x.

Masker answered 6/2, 2015 at 17:50 Comment(5)
The v2 endpoint is documented here: docs.docker.com/registry/spec/api/#listing-image-tagsPronty
What is this tutum.co website that you say I should give them my dockerhub login and password?Recap
@Recap When I wrote this answer, several years ago, Tutum was a service that provided a private Docker Registry. And I'm not "giving them" my password, I authenticate with their service using standard HTTP basic authentication over https.Masker
Tutum doesn't exist anymore. Can you update your reply so people don't accidentally send their credentials to whoever owns that domain now?Daleth
I updated the answer to use myrepo.example. I will need to be approved before it's updated.Amora
P
14

As of 2023, there are a number of tools to do this

docker run --rm ghcr.io/regclient/regctl:v0.4.5 tag ls ghcr.io/regclient/regctl      

docker run --rm quay.io/skopeo/stable:v1.9.2 list-tags docker://quay.io/skopeo/stable \
  | jq -r '.Tags[]'

docker run --rm gcr.io/go-containerregistry/crane ls gcr.io/go-containerregistry/crane  

docker run --rm r.j3ss.co/reg:v0.16.1 tags r.j3ss.co/reg

BTW - there are even more tools. This list looks comprehensive:
iximiuz/awesome-container-tinkering.

Pages answered 12/1, 2023 at 9:51 Comment(2)
Last month, after reading your answer, I decided to give skopeo a try on my Mac, so I did "brew install skopeo". This morning, I came back to my laptop, and happily saw that brew is still working on it without any crash. I believe I will have skopeo to use in the next month =)Vindictive
🤯 You could always use it via docker, as stated in the post. For convenience an alias helps. I do that a lot, e.g. with regctl: github.com/schnatterer/dotfiles/blob/…Pages
F
11

podman

Podman is a drop-in replacement for docker with more functionality, the principal differences are that it doesn't require a daemon and does not run as root. If you are using podman, you can use podman search

# podman search --list-tags <image name> --limit 1000
podman search --list-tags docker.io/alpine --limit 1000

There is a docker command for it, but I couldn't find the list-tags option.

Finalize answered 15/5, 2023 at 12:6 Comment(1)
why does this not show the latest versions of any image?Borneol
D
10

Building on Yan Foto's answer (the v2 api), I created a simple Python script to list the tags for a given image.

Usage:

./docker-registry-list.py alpine

Output:

{
  "name": "library/alpine",
  "tags": [
    "2.6",
    "2.7",
    "3.1",
    "3.2",
    "3.3",
    "3.4",
    "3.5",
    "3.6",
    "3.7",
    "edge",
    "latest"
  ]
}
Doublet answered 26/3, 2018 at 15:26 Comment(1)
please add a license to your repo otherwise no one can use itDelirium
C
7

See CLI utility: https://www.npmjs.com/package/docker-browse

Allows enumeration of tags and images.

docker-browse tags <image> will list all tags for the image. e.g. docker-browse tags library/alpine

docker-browse images will list all images in the registry. Not currently available for index.docker.io.

You may connect it to any registry, including your private one, so long as it supports Docker Registry HTTP API V2

Containerize answered 30/8, 2017 at 13:37 Comment(0)
A
7

You can achieve by running on terminal this:

curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/mysql/tags/' | jq . | grep name

Also, if you don't have jq you have to install it by

sudo apt-get install jq
Algesia answered 28/6, 2019 at 20:56 Comment(4)
curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/mysql/tags/' | jq .results[].name will save you a grep commandShipway
using version 1: curl -L -s 'https://registry.hub.docker.com/v1/repositories/danilobatistaqueiroz/job-wq-1/tags'Shantell
This only returns the tags on the :latest image. @sigjuice's answer has the jq form to use to retrieve all tags for the image. Even then, note that only the current platform tags will be retrieved. There may be (for example, on Python images) additional architectures and tags available beyond this list.Selfabnegation
This only returns the tags on the :latest image. @sigjuice's answer has the jq form to use to retrieve all tags for the image. Also, any v2 solution is limited to 100 results per page, so for images with a large number of tags (Python currently has 1989), you'll need to implement paging.Selfabnegation
R
5

Here's a Powershell script I wrote for Windows. Handles v1 and v2 repos:

Get-DockerImageVersions.ps1:

param (
  [Parameter (Mandatory=$true)]$ImageName,
  [Parameter (Mandatory=$false)]$RegistryURL
)

if (!$RegistryURL) 
{
  $RegistryURL = "https://registry.hub.docker.com/v1/repositories"
}

$list = ""
if ($RegistryURL -like "*v2*") 
{
  $list = "/list"
}

$URL = "$RegistryURL/$ImageName/tags$list"

write-debug $URL
$resp = Invoke-WebRequest -UseBasicParsing $URL | ConvertFrom-Json

if ($RegistryURL -like "*v2*") 
{
  $tags = $resp | select tags
  $tags.tags
} else {
  $tags = $resp | select name
  $tags.name
}
Roberts answered 12/7, 2018 at 18:4 Comment(0)
P
4

Get all tags from Docker Hub: this command uses the command-line JSON processor jq to select the tag names from the JSON returned by the Docker Hub Registry (the quotes are removed with tr). Replace library with the Docker Hub user name, debian with the image name:

curl -s 'https://registry.hub.docker.com/v2/repositories/library/debian/tags/' | jq -r '."results"[]["name"]'
Photophobia answered 28/5, 2017 at 7:54 Comment(1)
Please consider adding a small explanation as of why this answer the question, what does it do, ...Stamford
G
4

To view all available tags in a browser:

https://registry.hub.docker.com/v1/repositories/<username>/<image_name>/tags

i.e. https://hub.docker.com/r/localstack/localstack/tags

Or, you can get a json response using this endpoint:

https://registry.hub.docker.com/v1/repositories/localstack/localstack/tags

Germin answered 5/6, 2019 at 17:13 Comment(0)
Z
4

My contribution:

  • Shell script
  • As short and simple as possible
  • Requires curl and jq
  • Uses Docker v2 REST API
  • Returns all tags using REST API pagination

Example:

$ docker-tags prantlf/chromedriver-headless
latest
102
93
86

Script contents:

#!/bin/sh

image=$1
if [ "$image" == "" ]; then
  echo "Usage:
  docker-tags <image>

Example:
  docker-tags library/ubuntu"
  exit 0
fi

page_size=100
page_index=0
while true; do 
  page_index=$((page_index+1))
  results=`curl -L -s "https://registry.hub.docker.com/v2/repositories/$image/tags?page=$page_index&page_size=$page_size" | jq -r 'select(.results != null) | .results[]["name"]'`
  if [ $? != 0 ] || [ "$results" == "" ]; then
    break
  fi
  echo "$results"
done
Zeringue answered 23/10, 2022 at 19:16 Comment(0)
S
3
curl -u <username>:<password> https://$your_registry/v2/$image_name/tags/list -s -o - | \
    tr -d '{' | tr -d '}' | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | \
    awk -F: '{print $3}' | sed -e 's/,/\n/g'

You can use it if your env has no 'jq', = )

Sec answered 26/4, 2017 at 4:14 Comment(0)
E
3

You can use:

skopeo inspect docker://<REMOTE_REGISTRY> --authfile <PULL_SECRET> | jq .RepoTags
Edette answered 7/2, 2021 at 7:41 Comment(0)
T
3

Here is a script that lists all tags either with 2 or 3 digits. You can get the code directly on github https://github.com/youssefalaoui/dockerhub-tools/blob/main/dockerhub-list-tags.sh

dockerhub_list_tags()
{
    #local LOCAL_IMAGE LOCAL_GET_TWO_DIGITS_VERSIONS
     
    LOCAL_IMAGE=${1:-null}
    LOCAL_GET_TWO_DIGITS_VERSIONS=${2:-true}


    if [[ $LOCAL_IMAGE == "" || $LOCAL_IMAGE == null ]]
    then
        printf "Image name is required: %s" ${FUNCNAME[0]}; 
        exit 1;
    fi

    #[[ $LOCAL_IMAGE == "" || $LOCAL_IMAGE == null ]] && printf "Image name is required: %s" ${FUNCNAME[0]}; exit 1;

    echo "Listing tags from docker hub for your image '$LOCAL_IMAGE'"
    
    # Check if 2 digits format is requested, otherwise, show it in normal format
    
    if [[ "$LOCAL_GET_TWO_DIGITS_VERSIONS" == true ]]; then
        DOCKERHUB_LIST_TAGS=($(curl -L -s "https://registry.hub.docker.com/v2/repositories/$LOCAL_IMAGE/tags?page_size=1024"|jq '."results"[]["name"]' | sed 's/"//g' | sed 's/\.[^.]*$//'))
    else
        DOCKERHUB_LIST_TAGS=($(curl -L -s "https://registry.hub.docker.com/v2/repositories/$LOCAL_IMAGE/tags?page_size=1024"|jq '."results"[]["name"]' | sed 's/"//g'))
    fi

    for TAG in ${DOCKERHUB_LIST_TAGS[@]}
    do
    echo $TAG
    done
}


# Test example
dockerhub_list_tags "library/nginx" false
Tropology answered 10/9, 2022 at 6:27 Comment(0)
P
2

You can also use this scrap :

# vim /usr/sbin/docker-tags 

& Append Following (as it is):

#!/bin/bash
im="$1"
[[ -z "$im" ]] && { echo -e '\e[31m[-]\e[39m Where is the image name ??' ; exit ; }
[[ -z "$(echo "$im"| grep -o '/')" ]] && { link="https://hub.docker.com/r/library/$im/tags/" ; } || { link="https://hub.docker.com/r/$im/tags/" ; }
resp="$(curl -sL "$link")"
err="$(echo "$resp" | grep -o 'Page Not Found')"
if [[ ! -z "$err" ]] ; then
    echo -e "\e[31m[-]\e[39m No Image Found with name => [ \e[32m$im\e[39m ]"
    exit
else
    tags="$(echo "$resp"|sed  -e 's|}|\n|g' -e 's|{|\n|g'|grep '"result"'|sed -e 's|,|\n|g'|cut -d '[' -f2|cut -d ']' -f1|sed  '/"tags":/d'|sed -e 's|"||g')"
    echo -e "\e[32m$tags\e[39m"
fi

Make it Executable :

# chmod 755 /usr/sbin/docker-tags

Then Finally Try By :

$ docker-tags testexampleidontexist
   [-] No Image Found with name => [ testexampleidontexist ]

$ docker search ubuntu

$ docker-tags teamrock/ubuntu
   latest

[ Hope you are aware of $ & # before running any command ]

Praseodymium answered 6/4, 2017 at 17:33 Comment(0)
K
2

If folks want to read tags from the RedHat registry at https://registry.redhat.io/v2 then the steps are:

# example nodejs-12 image
IMAGE_STREAM=nodejs-12
REDHAT_REGISTRY_API="https://registry.redhat.io/v2/rhel8/$IMAGE_STREAM"
# Get an oAuth token based on a service account username and password https://access.redhat.com/articles/3560571
TOKEN=$(curl --silent -u "$REGISTRY_USER":"$REGISTRY_PASSWORD" "https://sso.redhat.com/auth/realms/rhcc/protocol/redhat-docker-v2/auth?service=docker-registry&client_id=curl&scope=repository:rhel:pull" |  jq --raw-output '.token')
# Grab the tags
wget -q --header="Accept: application/json" --header="Authorization: Bearer $TOKEN" -O - "$REDHAT_REGISTRY_API/tags/list" | jq -r '."tags"[]' 

If you want to compare what you have in your local openshift registry against what is in the upstream registry.redhat.com then here is a complete script.

Kerosene answered 27/12, 2019 at 21:11 Comment(0)
C
2

In powershell 5.1, I have a simple list_docker_image_tags.ps1 script like this:

[CmdletBinding()]
param (
    [Parameter(Mandatory = $true)]
    [string]
    $image
)

$url = "https://registry.hub.docker.com/v1/repositories/{0}/tags" -f $image 
Invoke-WebRequest $url  | ConvertFrom-Json | Write-Output

Then I can grep for 4.7 tags like this:

./list_docker_image_tags.ps1 microsoft/dotnet-framework | ?{ $_.name -match "4.7" }
Celiotomy answered 28/3, 2020 at 15:55 Comment(0)
M
2

Here's an answer that's applicable for v2 of the registry.

If you have jq and curl installed on your machine:

curl https://registry.hub.docker.com/v2/repositories/$REPOSITORY/tags?page_size=10000 | jq '.results[] | { name: .name, architectures: ([ (.images[] | if .variant? then .os + "/" + .architecture + .variant? else .os + "/" + .architecture end) ] | join(", ")) }'

For instance, running this command for the curlimages/curl repository yields:

{
  "name": "latest",
  "architectures": "linux/ppc64le, linux/s390x, linux/arm64, linux/386, linux/armv7, linux/amd64"
}
{
  "name": "7.78.0",
  "architectures": "linux/armv7, linux/arm64, linux/386, linux/s390x, linux/ppc64le, linux/amd64"
}
{
  "name": "7.77.0",
  "architectures": "linux/ppc64le, linux/arm64, linux/s390x, linux/armv7, linux/386, linux/amd64"
}
{
  "name": "7.76.1",
  "architectures": "linux/386, linux/arm64, linux/armv7, linux/ppc64le, linux/s390x, linux/amd64"
}
{
  "name": "7.76.0",
  "architectures": "linux/armv7, linux/386, linux/s390x, linux/amd64, linux/ppc64le, linux/arm64"
}
{
  "name": "7.75.0",
  "architectures": "linux/armv7, linux/ppc64le, linux/386, linux/amd64, linux/arm64, linux/s390x"
}
{
  "name": "7.74.0",
  "architectures": "linux/armv7, linux/386, linux/amd64, linux/ppc64le, linux/s390x, linux/arm64"
}
{
  "name": "7.73.0",
  "architectures": "linux/arm64, linux/armv7, linux/s390x, linux/ppc64le, linux/amd64, linux/386"
}
{
  "name": "7.72.0",
  "architectures": "linux/s390x, linux/amd64, linux/arm64, linux/386, linux/ppc64le, linux/armv7"
}
{
  "name": "7.71.1",
  "architectures": "linux/s390x, linux/arm64, linux/ppc64le, linux/amd64, linux/386, linux/armv7"
}
{
  "name": "7.71.0",
  "architectures": "linux/arm64, linux/ppc64le, linux/386, linux/s390x, linux/amd64, linux/armv7"
}
{
  "name": "7.70.0",
  "architectures": "linux/386, linux/arm64, linux/s390x, linux/amd64, linux/ppc64le, linux/armv7"
}
{
  "name": "7.69.1",
  "architectures": "linux/amd64"
}
{
  "name": "7.69.0",
  "architectures": "linux/amd64"
}
{
  "name": "7.68.0",
  "architectures": "linux/amd64"
}
{
  "name": "7.67.0",
  "architectures": "linux/amd64"
}
{
  "name": "7.66.0",
  "architectures": "linux/amd64"
}
{
  "name": "7.65.3",
  "architectures": "linux/amd64"
}
Matazzoni answered 1/8, 2021 at 15:47 Comment(1)
Useful, but keep in mind that V2 responses are limited to 100 results per page (the page_size=10000 has no effect above 100). You'll need to implement paging to be sure of all results. Python, for instance, currently has 1989 tags.Selfabnegation
J
2

There is a lot of duplication among the answers given thus far. Most of them fail to take into account that the Docker Hub API (at least v2) will never return more than 100 results at a time, even if you ask for more. I noticed this when requesting the tags for php.

The following script works around this. It only works for public repositories.

#!/bin/sh

# list the tags on Docker Hub for the given image(s)
# thank you, https://mcmap.net/q/80902/-how-can-i-list-all-tags-for-a-docker-image-on-a-remote-registry

TagsFor()
{
  curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/'$1'/tags?page='$2'&page_size'=$3
}

for i in "$@"
do
  TagsFor "$i" 1 10 |
  jq -r .count |
  while read nr_of_tags
  do
    nr_of_pages=`expr $nr_of_tags / 100`
    seq 1 $nr_of_pages |
    while read p
    do
      TagsFor "$i" "$p" 100 |
      jq -r '.results[] | .name'
    done
  done
done

I just ran the script; it retrieved 7200 php tags. For all I know, it may be running into yet another API limit, but 7200 >> 100.

Jetpropelled answered 2/9, 2022 at 8:22 Comment(3)
Why do you mention GitHub API?Thereon
No idea. Fixed. Thanks!Jetpropelled
PS: when I wrote this answer, I wasn't aware of docker search.Jetpropelled
S
1

The Docker Registry API has an endpoint to list all tags.

Looks like Tutum has a similar endpoint, as well as a way to access via tutum-cli.

With the tutum-cli, try the following:

tutum tag list <uuid>
Sevenup answered 4/2, 2015 at 12:45 Comment(1)
I don't think this works for registry images. I just get a "Identifier '<id>' does not match any service, node or nodecluster".Masker
H
1

Edit: In answer to the question:

How can I list all tags of a Docker image on a remote Docker registry using the CLI (preferred) or curl?

Preferably without pulling all versions from the remote registry. I just want to list the tags.

To get all the tags for an image you can use "curl" to get the specific image you want and pipe the output into "jq" to extract the information.

curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/python/tags?page_size=1024'|jq  '.results[]["name"]'    

Output (truncated not the full list):

"3.9-windowsservercore"  
"alpine3.14"  
"alpine3.13"  
"alpine"  
"3.9.8-alpine3.14"  
"3.9.8-alpine3.13"
"3.9.8-alpine"

Further should you need additional information from the registry you can access additional field information like this.

This command will give you both the tags and the size of the image which might be useful to have too.

curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/python/tags?page_size=1024'|jq  '.results[] as $results | ($results["name"] + " - " + ($results["full_size"] | tostring))'

Output (truncated not the full list):

 "3.9-windowsservercore - 2241040278"  
 "alpine3.14 - 17565702"  
 "alpine3.13 - 17556181"  
 "alpine - 17565702"  
 "3.9.8-alpine3.14 -17362557"  
 "3.9.8-alpine3.13 - 17353629"  
 "3.9.8-alpine - 17362557"  
Hasid answered 27/11, 2021 at 8:5 Comment(3)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Marmara
Or to list just the tags: curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/python/tags?page_size=1024' | jq '.results[] | .name', and use jq -r to get rid of the quotes.Jetpropelled
At least right now, pages sizes larger than 100 are equivalent to 100 - more results will not be supplied. However, the JSON contains a link to a next page, which can of course be followed to obtain more results.Jetpropelled
L
1

Building on @AlexForbes's answer I've improved the api v2 docker-registry-list.py to support:
  – slashes in the repository name (eg curlimages/curl) and
  – private repos (authentication by username and password)

https://github.com/axil/docker-registry-list

Usage:

./docker-registry-list.py -u dockerid -p password dockerid/myrepo

Output:

{
  "name": "dockerid/myrepo",
  "tags": [
    "1.0"
  ]
}
Linnette answered 28/1, 2022 at 11:43 Comment(6)
you must add an open source licenseDelirium
@Delirium The original code does not have a license. "Without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work." (github docs). Not only I am not eligible to add a license, but I am also not allowed to even create any derivatives, let alone publish them. I've published them on my own risk and can potentially be sued for this.Linnette
I know code must have a license to redistribute, that's why I asked - I missed that this isn't your work and have asked the original authorDelirium
@Delirium Yes, that's the right question to ask. I would only object to the word 'must' ;) Would it be my own work, I could potentially add a more restrictive license than 'open source'.Linnette
Anyway, I raised an issue in @AlexForbes repository and he added the license and I merged it in.Linnette
ty 123456789012Delirium
D
0

I have done this thing when I have to implement a task in which if user somehow type the wrong tag then we have to give the list of all the tag present in the repo(Docker repo) present in the register. So I have code in batch Script.

<html>
<pre style="background-color:#bcbbbb;">
@echo off

docker login --username=xxxx --password=xxxx
docker pull %1:%2

IF NOT %ERRORLEVEL%==0 (
echo "Specified Version is Not Found "
echo "Available Version for this image is :"
for /f %%i in (' curl -s -H "Content-Type:application/json" -X POST -d "{\"username\":\"user\",\"password\":\"password\"}" https://hub.docker.com/v2/users/login ^|jq -r .token ') do set TOKEN=%%i
curl -sH "Authorization: JWT %TOKEN%" "https://hub.docker.com/v2/repositories/%1/tags/" | jq .results[].name
)
</pre>
</html>

So in this we can give arguments to out batch file like:

Dockerfile java version7 
Donee answered 26/12, 2018 at 11:26 Comment(0)
C
0

Was looking for an sdk in java that I could use to hit the Docker V2 API but couldn't find one. Repo here for anyone that might find it useful: https://github.com/fern-api/docker-registry-api.

Should be possible to generate in other languages too, feel free to open an issue on the repo!

Cherie answered 14/7, 2022 at 22:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.