From 6fae25b305d714b3ab7608fa003f1af9bf024545 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 14 Feb 2023 13:33:23 +0800 Subject: Rename tools into bin --- bin/docker/dktags | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/docker/dktags (limited to 'bin/docker') diff --git a/bin/docker/dktags b/bin/docker/dktags new file mode 100755 index 0000000..5a91434 --- /dev/null +++ b/bin/docker/dktags @@ -0,0 +1,29 @@ +#!/bin/bash + +# Orignally copied from https://stackoverflow.com/a/39454426/7051075 + +if [ $# -lt 1 ] +then +cat << HELP + +dktags -- list all tags for a Docker image on a remote registry. + +EXAMPLE: + - list all tags for ubuntu: + dktags ubuntu + + - list all php tags containing apache: + dktags php apache + +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}" -- cgit v1.2.3-70-g09d2