Skip to content

Instantly share code, notes, and snippets.

@madsonic
Last active December 14, 2020 10:02
Show Gist options
  • Save madsonic/3ee4662a778ffb06ab661894767f9626 to your computer and use it in GitHub Desktop.
Save madsonic/3ee4662a778ffb06ab661894767f9626 to your computer and use it in GitHub Desktop.
check docker hub rate limit balance
# annonymous
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" \
| jq -r .token) && curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest \
| grep 'RateLimit'
# authenticated
# note that there should be no output
# https://docs.docker.com/docker-hub/download-rate-limit/#i-dont-see-any-ratelimit-headers
TOKEN=$(curl --user 'username:password' "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) \
&& curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest \
| grep 'RateLimit'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment