Getting the Tags of Docker Images on Docker Hub

Getting the Tags of Docker Images on Docker Hub

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.


#!/bin/bash

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

Related Article