From 121ddf8fcf7fefe4807ba54f8860f7997984c5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 27 Aug 2018 14:56:03 +0200 Subject: [PATCH] Small script to list all tags of a Docker image From Docker Hub. --- docker/imagetags | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 docker/imagetags diff --git a/docker/imagetags b/docker/imagetags new file mode 100755 index 0000000..e8ac069 --- /dev/null +++ b/docker/imagetags @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ $# -lt 1 ] +then +cat << HELP + +imagetags -- list all tags for a Docker image on a remote registry. + +EXAMPLE: + - list all tags for ubuntu: + imagetags ubuntu + + - list all php tags containing apache: + imagetags php apache + + - list all tags of RocketChat : + imagetags "rocketchat/rocket.chat" + +HELP +fi + +image="$1" +tags=$(wget -q https://registry.hub.docker.com/v1/repositories/"${image}"/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}') + +if [ -n "$2" ] +then + tags=$(echo "${tags}" | grep "${2}") +fi + +echo "${tags}"