# docker-tags

  • # 获取远程镜像的所有版本号

    #获取tomcat镜像全部版本号
    sh docker-tags.sh tomcat
    

    docker-tags.sh的内容为如下

#!/bin/bash
function usage() {
cat << HELP
 
dockertags  --  list all tags for a Docker image on a remote registry.
 
EXAMPLE: 
    - list all tags for nginx:
       docker-tags nginx
 
    - list all php tags containing apache:
       docker-tags 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}"