Skip to content

Instantly share code, notes, and snippets.

@kosu9i
Last active November 7, 2020 01:02
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 kosu9i/efb54c53d6442ce0bfb649c8542d9a8b to your computer and use it in GitHub Desktop.
Save kosu9i/efb54c53d6442ce0bfb649c8542d9a8b to your computer and use it in GitHub Desktop.
One-liner for checking my limitation of Docker Hub pull

Require jq command

cf. Download rate limit

For anonymous user

$ curl --head -H "Authorization: Bearer $(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4369    0  4369    0     0   5412      0 --:--:-- --:--:-- --:--:--  5407
RateLimit-Limit: 2500;w=21600
RateLimit-Remaining: 2500;w=21600

For docker hub user account

$ curl --head -H "Authorization: Bearer $(curl --user '<User Name>:<Password>' "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4464    0  4464    0     0   4710      0 --:--:-- --:--:-- --:--:--  4713
RateLimit-Limit: 2500;w=21600
RateLimit-Remaining: 2496;w=21600
@kosu9i
Copy link
Author

kosu9i commented Nov 6, 2020

keep in mind that requesting a manifest emulates a pull and will count against the limits

とある。↑のチェック自体もpull回数に含まれて消費されるっぽい。
ただ、なぜか2回実行して1回分消費される挙動。

@shawnaxsom
Copy link

Thanks for sharing! Please make sure you are using --head in the curl request. We've updated the registry so that HEAD requests won't count against the limits: https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate

@kosu9i
Copy link
Author

kosu9i commented Nov 7, 2020

Thank you for your advice!
I fixed my gist code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment