Created
September 22, 2017 15:42
-
-
Save dymurray/502272351bf9ee5eb2593de627edc7ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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