Skip to content

Instantly share code, notes, and snippets.

@jriguera
Last active April 12, 2017 11:53
Show Gist options
  • Save jriguera/4bd5140a6aecb902a09a3f0fec2b4455 to your computer and use it in GitHub Desktop.
Save jriguera/4bd5140a6aecb902a09a3f0fec2b4455 to your computer and use it in GitHub Desktop.
Listing Docker images in DockerHub
#!/bin/bash
# Based on kizbitz/dockerhub-v2-api-organization.sh at https://gist.github.com/kizbitz/175be06d0fbbb39bc9bfa6c0cb0d4721
# 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
UNAME=""
UPASS=""
ORG=""
# -------
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 ordered by last_updated
curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${ORG}/?page_size=200 | jq '.results|sort_by(.last_updated)|.[]|.namespace + "/" + .name + " updated=" + .last_updated'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment