Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get the list of images and tags for a Docker Hub user account.
# Example for the Docker Hub V2 API
# Returns all imagas and tags associated with a Docker Hub user account.
# Requires 'jq':
# set username and password
# -------
set -e
# aquire token
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' | jq -r .token)
# get list of repositories for the user account
REPO_LIST=$(curl -s -H "Authorization: JWT ${TOKEN}"${UNAME}/?page_size=100 | jq -r '.results|.[]|.name')
# build a list of all images & tags
for i in ${REPO_LIST}
# get tags for repo
IMAGE_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}"${UNAME}/${i}/tags/?page_size=100 | jq -r '.results|.[]|.name')
# build a list of images from tags
for j in ${IMAGE_TAGS}
# add each tag to list
# output
for i in ${FULL_IMAGE_LIST}
echo ${i}
Copy link

Where can I find the official documentation for this docker hub v2 api?

Copy link

Just to add here: This will fetch any user's public repos irrespective of the authorised user.

Copy link

ghost commented Sep 9, 2020

Worked like wonders, for my naive repos <3

Copy link

avarne commented Jan 13, 2021

There is a page_size parameter specified in the REST API call which means only 100 images at a time will get listed down. What if I want to list down all images?

Copy link

thanks for the script

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