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}'"}' \ | jq -r .token)
  1. Pull the stats:
curl -L -H "Authorization: Bearer $TOKEN" \ \
    | jq -r '.pull_count'

Thanks to Arthur Koziel’s Blog

Leave a Reply

Your email address will not be published.

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