Skip to content

Instantly share code, notes, and snippets.

@ngquerol
Created September 8, 2016 17:52
Show Gist options
  • Save ngquerol/9265746a922e0daaaf0a3107364d836e to your computer and use it in GitHub Desktop.
Save ngquerol/9265746a922e0daaaf0a3107364d836e to your computer and use it in GitHub Desktop.
List all available tags for a given docker image
dockertags() {
if [ -z ${1+x} ] || [ $# -ne 1 ]; then
echo "Usage: ${0} <image name>"
else
local namespace="library"
local repository=$1
if [[ $1 == *"/"* ]]; then
namespace=${1%/*}
repository=${1#*/}
fi
curl -sS "https://registry.hub.docker.com/v2/repositories/${namespace}/${repository}/tags/" | jq -r 'try .results[].name catch "Image not found."' | sort
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment