在使用 docker pull 拉取鏡像時,遇到如下報錯:
Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
2020 年 11 月 20 日,Docker Hub 基于個人 IP 地址對匿名和免費認證的用戶進行了鏡像拉取次數(shù)的限制。
對于匿名用戶,限制設置為每個 IP 地址每 6 小時 100 次拉取。
對于經(jīng)過身份驗證的用戶,每 6 小時 200 次拉取。
那么如何查看我們剩余的拉取次數(shù)呢?
匿名用戶獲取令牌:
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
認證用戶獲取令牌:
TOKEN=$(curl --user 'username:password' "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
root@nianyu-virtual-machine:~# curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
HTTP/1.1 200 OK
content-length: 2782
content-type: application/vnd.docker.distribution.manifest.v1+prettyjws
docker-content-digest: sha256:767a3815c34823b355bed31760d5fa3daca0aec2ce15b217c9cd83229e0e2020
docker-distribution-api-version: registry/2.0
etag: "sha256:767a3815c34823b355bed31760d5fa3daca0aec2ce15b217c9cd83229e0e2020"
date: Mon, 09 Jan 2023 07:50:24 GMT
strict-transport-security: max-age=31536000
ratelimit-limit: 200;w=21600
ratelimit-remaining: 200;w=21600
docker-ratelimit-source: 4f2ba4fd-e2ab-4ff4-a284-e50796bc7960
這意味著我的限制是每 21600 秒(6 小時)拉取 200 次,我還可以拉取 200次。
參考:https://www.docker.com/inc
https://docs.docker.com/docker-hub/download-rate-limit/#how-do-i-authenticate-pull-requests