Skip to content

Instantly share code, notes, and snippets.

@dymurray
Created September 22, 2017 15:42
Show Gist options
  • Save dymurray/502272351bf9ee5eb2593de627edc7ce to your computer and use it in GitHub Desktop.
Save dymurray/502272351bf9ee5eb2593de627edc7ce to your computer and use it in GitHub Desktop.
#!/bin/bash
# Example for the Docker Hub V2 API
# Returns all images and tags associated with a Docker Hub organization account.
# Requires 'jq': https://stedolan.github.io/jq/
# set username, password, and organization
# NOTE: We're expecting to break the dependency upon this script soon.
UNAME=$2
UPASS=$3
ORG=$1
# -------
set -e
# get token
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${UNAME}'", "password": "'${UPASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
# get list of repositories
REPO_LIST=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${ORG}/?page_size=100 | jq -r '.results|.[]|.name')
for i in ${REPO_LIST}
do
echo "${ORG}/${i}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment