Skip to content

Instantly share code, notes, and snippets.

@ManzDev
Created August 5, 2019 03:07
Show Gist options
  • Save ManzDev/0610e0b9f5a1ec55ae06ef63dc0ccb6c to your computer and use it in GitHub Desktop.
Save ManzDev/0610e0b9f5a1ec55ae06ef63dc0ccb6c to your computer and use it in GitHub Desktop.
Search tags in docker hub
#!/bin/bash
if [ $# -lt 1 ]
then
cat << HELP
dockertags - list all tags for a Docker image on a remote registry.
SYNTAX: dockertags <image> [tag-word]
$ dockertags ubuntu -- list all tags for ubuntu
$ dockertags php fpm -- list all php tags containing fpm
$ dockertags debian buster -- list all debian tags containing buster
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