-
Notifications
You must be signed in to change notification settings - Fork 1
/
dockertags
executable file
·50 lines (36 loc) · 1 KB
/
dockertags
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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 -i ubuntu
- list all php tags containing apache (regular expression should be working):
dockertags -c apache -i php
- list all frolvlad/alpine-glibc tags excluding 3.2 (regular expression should be working)
dockertags -e 3.2 -i frolvlad/alpine-glibc
HELP
fi
while getopts ":i:c:e:" opt; do
case $opt in
i) image="$OPTARG"
;;
c) contains="$OPTARG"
;;
e) excludes="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done
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 "${contains}" ]
then
tags=` echo "${tags}" | grep -E "${contains}" `
fi
if [ -n "${excludes}" ]
then
tags=` echo "${tags}" | grep -E -v "${excludes}" `
fi
echo "${tags}"