镜像标签检索小工具
#!/bin/sh
#
# Simple script that will display docker repository tags.
#
# Usage:
# $ docker-tags-search.sh centos gitea/gitea
function showUsage() {
echo "Usage:"
echo "`basename $0 .sh` centos gitea/gitea"
}
function search() {
for str in $* ; do
if [[ $str == *"/"* ]]; then
project=`echo $str|awk -F '/' '{print $1}'`
repo=`echo $str|awk -F '/' '{print $2}'`
else
project="library"
repo=$str
fi
echo "$project/$repo tags:"
curl -s -S "https://registry.hub.docker.com/v2/repositories/$project/$repo/tags/" | \
sed -e 's/,/,\n/g' -e 's/\[/\[\n/g' | \
grep '"name"' | \
awk -F\" '{print $4;}' | \
sort -fu | \
sed -e "s/^/${Repo}:/"
done
}
type curl >/dev/null 2>&1 || { echo >&2 "require curl but it's not installed, abort!"; exit 1; }
if [ $# -lt 1 ]; then
showUsage
exit 0
fi
search $*
©raveh.net