#!/bin/bash
# https://stackoverflow.com/questions/28320134/how-can-i-list-all-tags-for-a-docker-image-on-a-remote-registry

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
exit 1
fi

image="$1"
tags=`curl -L -s "https://registry.hub.docker.com/v2/repositories/library/${image}/tags?page_size=1024" | jq -r '."results"[]["name"]'`

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

echo "${tags}"

How can I list all tags for a Docker image on a remote registry? - Stack Overflow