DockerHub API to Get Statistics

I had to gather statistics for my team’s repo. Here is a small recipe to get the pull count for a specific repository .

  1. Setup the Bearer Token.
export DOCKER_USERNAME="prb112"
export DOCKER_PASSWORD="<<>>"

export TOKEN=$(curl -s -H "Content-Type: application/json" \
   -X POST -d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' \
   https://hub.docker.com/v2/users/login/ | jq -r .token)
  1. Pull the stats:
curl -L -H "Authorization: Bearer $TOKEN" \
    https://hub.docker.com/v2/repositories/ibmcom/ibm-fhir-server \
    | jq -r '.pull_count'
574725

Thanks to Arthur Koziel’s Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.