shell腳本列出docker所有tag

docker-tags-list.sh

#!/bin/bash
# -----------------------------------------------------------------
# FileName: docker-tags-list.sh
# Date: 2021-12-24
# Author: jiftle
# Description: 
# -----------------------------------------------------------------
set -x

function usage() {
cat << HELP
dockertags  --  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
}



if [ $# -lt 1 ]; then
    usage
    exit
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}"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章