Skip to content

Instantly share code, notes, and snippets.

@OndrejP
Last active November 28, 2019 00:52
Show Gist options
  • Save OndrejP/a2386d08e5308b0776c0 to your computer and use it in GitHub Desktop.
Save OndrejP/a2386d08e5308b0776c0 to your computer and use it in GitHub Desktop.
list all images on Docker Register v2
#!/bin/bash
export Register=https://register.example.com
export cLink="/v2/_catalog?n=10"
export cFile=docker.register.catalog
export tFile=docker.register.tags
export wgetC="wget -O- -q -S "
# Usage with user/password
# export wgetC="wget -O- -q -S --user=ondra --password=heslo "
function listFullCatalog {
while true; do
# If you need user/password , add --user= and --pasword= ; Thanks rmetzger
${wgetC} "${Register}${cLink}" \
2>${cFile} \
| json_pp -t json | grep -F " " | cut -d\" -f2 | listTags
cLink=`grep Link ${cFile} 2>/dev/null | cut -d\< -f2 | cut -d\> -f1`
if [ ! -n "${cLink}" ] ; then break; fi
done
}
function listTags {
cat - | while read image; do
tLink="/v2/${image}/tags/list?n=10"
while true; do
# If you need user/password , add --user= and --pasword= ; Thanks rmetzger
${wgetC} "${Register}${tLink}" \
2>${tFile} \
| json_pp -t json | grep -F " " | cut -d\" -f2 | sed "s@^@${image}:@"
tLink=`grep Link ${tFile} 2>/dev/null | cut -d\< -f2 | cut -d\> -f1`
if [ ! -n "${tLink}" ] ; then break; fi
done
done
}
listFullCatalog
@flickerfly
Copy link

Other useful wget options:
--header="key:value" is useful for an API key to be passed in
--no-check-certificates is useful when using self-signed certs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment