zoukankan      html  css  js  c++  java
  • 命令方式取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}"
    

    执行结果

    ❯ ./docker-tags-list.sh mysql |head
    latest
    5
    5.5
    5.5.40
    5.5.41
    5.5.42
    5.5.43
    5.5.44
    5.5.45
    5.5.46
    5.5.47
    
  • 相关阅读:
    vim常用命令
    转:CRF++总结1
    转:CRF++总结2
    并查集算法程序
    CRF++使用小结(转)
    并查集算法程序
    C#winform 画图
    转:字符识别
    转:A Survey On Relation Extraction
    转:生产计划问题
  • 原文地址:https://www.cnblogs.com/jiftle/p/15727182.html
Copyright © 2011-2022 走看看