diff options
| author | Hsieh Chin Fan <typebrook@gmail.com> | 2022-04-05 18:03:51 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <typebrook@gmail.com> | 2022-04-05 18:03:51 +0800 |
| commit | 5456eb312fbcfde82c909789f02aa114a54f0957 (patch) | |
| tree | 3e1f9eec75b2ac78bf744a4bcfa8ae5c1fe25505 | |
| parent | 13e4cd409373a1ab9cc2f574c286582eef6cbe51 (diff) | |
update
| -rw-r--r-- | .signature | 2 | ||||
| -rwxr-xr-x | tools/docker/dktags | 29 |
2 files changed, 30 insertions, 1 deletions
| @@ -1 +1 @@ | |||
| 謝晉凡 Hsieh Chin Fan | https://topo.tw | 謝晉凡 Hsieh Chin Fan | https://topo.tw/about | ||
diff --git a/tools/docker/dktags b/tools/docker/dktags new file mode 100755 index 0000000..5a91434 --- /dev/null +++ b/tools/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}" | ||