Small script to list all tags of a Docker image

From Docker Hub.
This commit is contained in:
Jeremy Gardais 2018-08-27 14:56:03 +02:00
parent 19df5e41fb
commit 121ddf8fcf
1 changed files with 30 additions and 0 deletions

30
docker/imagetags Executable file
View File

@ -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}"