Skip to content

Instantly share code, notes, and snippets.

@navono
Created April 22, 2019 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navono/4c25641b3693f3b5e7f4f2116d91b317 to your computer and use it in GitHub Desktop.
Save navono/4c25641b3693f3b5e7f4f2116d91b317 to your computer and use it in GitHub Desktop.
获取指定镜像的所有 tag
#!/bin/bash
if [ $# -lt 1 ]
then
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
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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment