Skip to content

Instantly share code, notes, and snippets.

@leetschau
Created September 26, 2016 08:45
Show Gist options
  • Save leetschau/a242b6630628429e3a3853991cb5c318 to your computer and use it in GitHub Desktop.
Save leetschau/a242b6630628429e3a3853991cb5c318 to your computer and use it in GitHub Desktop.
list all tags of an image in docker hub
#!/bin/sh
# From: http://stackoverflow.com/a/34054903/701420
# Simple script that will display docker repository tags.
#
# Usage:
# $ docker-show-repo-tags.sh ubuntu centos
for Repo in $* ; do
curl -s -S "https://registry.hub.docker.com/v2/repositories/library/$Repo/tags/" | \
sed -e 's/,/,\n/g' -e 's/\[/\[\n/g' | \
grep '"name"' | \
awk -F\" '{print $4;}' | \
sort -fu | \
sed -e "s/^/${Repo}:/"
done
@dylanninin
Copy link

Awesome. You can append a page_size=1024 query argument to this api, e.g.:

"https://registry.hub.docker.com/v2/repositories/library/$Repo/tags?page_size=1024"

and this will list almost all tags available.

Besides, following is a shell function version:

# Simple script that will display docker repository tags.
# Usage:
#   $ ds ubuntu centos
function ds() {
    for Repo in $* ; do
        curl -s -S "https://registry.hub.docker.com/v2/repositories/library/${Repo}/tags/?page_size=1024" | \
        sed -e 's/,/,\n/g' -e 's/\[/\[\n/g' | \
        grep '"name"' | \
        awk -F\" '{print $4;}' | \
        sort -fu | \
        sed -e "s/^/${Repo}:/"
    done
}

@norpol
Copy link

norpol commented Jul 7, 2018

Really nice, thank you for sharing. @dylanninin Exactly what I was looking for.

@kingbuzzman
Copy link

@dylanninin There is a hard limit of 100 items per page -- this is ignoring your other 924 items you're requesting.

I was able to get this working a while back ago like this: https://stackoverflow.com/questions/24481564/how-can-i-find-a-docker-image-with-a-specific-tag-in-docker-registry-on-the-dock/48931329#48931329

I just recently improved the pagination thanks you :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment