aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/docker/dktags
blob: 5a91434f56a99cd1dd76becb119fbb08c4ca94ed (plain)
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
#!/bin/bash

# Orignally copied from https://stackoverflow.com/a/39454426/7051075

if [ $# -lt 1 ]
then
cat << HELP

dktags  --  list all tags for a Docker image on a remote registry.

EXAMPLE: 
    - list all tags for ubuntu:
       dktags ubuntu

    - list all php tags containing apache:
       dktags 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}"