Getting the Tags of Docker Images on Docker Hub

Image for post
Image for post

Found a really useful little script that lets you quickly look up the available tags of any Docker image available on the Docker Hub. This comes in really handy because docker search will tell you the name of an image and a description, but doesn’t give you the available tags.

if [ $# -lt 1 ]; then
cat << HELP
dtags -- 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"
source="https://registry.hub.docker.com/v1/repositories/${image}/tags"
raw_tags=`wget -q $source -O -`
sed_tags=`echo $raw_tags | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g'`
tags=`echo $sed_tags | tr '}' '\n' | awk -F: '{print $3}'`
if [ -n "$2" ]; then
tags=` echo "${tags}" | grep "$2" `
fi
echo "${tags}"

Sources

Originally published on April 20, 2018.

Written by

I'm a technology enthusiast, always searching for better ways of doing things. Lately that has been all things React. I also write a lot on Medium. :)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store