diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2023-02-14 13:33:23 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2023-02-14 13:33:23 +0800 |
commit | 6fae25b305d714b3ab7608fa003f1af9bf024545 (patch) | |
tree | 05507b2c0505659d2fd847ecce988dacab63a236 /bin/docker | |
parent | 41ad31a2dee9ff912f222652f022b4c55cddcbf7 (diff) |
Rename tools into bin
Diffstat (limited to 'bin/docker')
-rwxr-xr-x | bin/docker/dktags | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/docker/dktags b/bin/docker/dktags new file mode 100755 index 0000000..5a91434 --- /dev/null +++ b/bin/docker/dktags | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Orignally copied from https://stackoverflow.com/a/39454426/7051075 | ||
4 | |||
5 | if [ $# -lt 1 ] | ||
6 | then | ||
7 | cat << HELP | ||
8 | |||
9 | dktags -- list all tags for a Docker image on a remote registry. | ||
10 | |||
11 | EXAMPLE: | ||
12 | - list all tags for ubuntu: | ||
13 | dktags ubuntu | ||
14 | |||
15 | - list all php tags containing apache: | ||
16 | dktags php apache | ||
17 | |||
18 | HELP | ||
19 | fi | ||
20 | |||
21 | image="$1" | ||
22 | 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}'` | ||
23 | |||
24 | if [ -n "$2" ] | ||
25 | then | ||
26 | tags=` echo "${tags}" | grep "$2" ` | ||
27 | fi | ||
28 | |||
29 | echo "${tags}" | ||