Last active
May 23, 2023 21:35
-
-
Save anapsix/6005df2ec91512c1fbe390136a420805 to your computer and use it in GitHub Desktop.
Naive script to check how many anonymous pulls from Docker hub remain / allowed from current IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
for dep in curl jq grep awk; do | |
if ! which ${dep} >&/dev/null; then | |
echo >&2 "ERROR: required ${dep} binary is not found, exiting.." | |
exit 1 | |
fi | |
done | |
TOKEN=$( | |
curl \ | |
-sS \ | |
"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" 2>&1 \ | |
| grep "^ratelimit-remaining" \ | |
| awk -F':| |;' '{print $3}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment