DockerHubAPI

nicolaw 10th April 2018 at 2:06pm
Docker jq JSON
curl -sSL \
    -H 'Content-Type: application/json' \
    https://hub.docker.com/v2/repositories/nicolaw/docker-python26ci/autobuild/ \
    | jq

Get List of Images

set -euo pipefail

main() {
  declare username="$1"
  declare password="$2"

  declare token=""
  token="$(curl -sSL -H "Content-Type: application/json" -X POST \
      -d '{"username": "'$username'", "password": "'$password'"} \
      https://hub.docker.com/v2/users/login/ | jq -r .token)"

  declare -a repolist
  repolist=($(curl -sSL -H "Authorization: JWT $token" \
      "https://hub.docker.com/v2/repositories/$username/?page_size=100" \
      | jq -r '.results|.[]|.name'))

  declare repo=""
  for repo in "${repolist[@]}"; do
    for imagetag in $(curl -sSL -H "Authorization: JWT $token" \
      "https://hub.docker.com/v2/repositories/$username/$repo/tags/?page_size=100" \
      | jq -r '.results|.[]|.name') ; do
      echo "$username/$repo:$imagetag"
    done
  done
}

main "$@"
$ curl -sSL "https://hub.docker.com/v2/repositories/nicolaw/?page_size=100" \
  | jq -r '.results[] as $res | $res.namespace + "/" + $res.name'
nicolaw/docker-python27ci
nicolaw/docker-python26ci
nicolaw/trinitycore
nicolaw/docker-shellci