Skip to content

Instantly share code, notes, and snippets.

@anapsix
Last active May 23, 2023 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anapsix/6005df2ec91512c1fbe390136a420805 to your computer and use it in GitHub Desktop.
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
#!/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