Docker build/pull with authentication

According to the following commands, when I supply my user name and password at hub.docker, the rate-limit is 200 and the remaining is also 200.

$ TOKEN=$(curl --user 'MY_USER:MY_PASS' "" | jq -r .token)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4477    0  4477    0     0  11689      0 --:--:-- --:--:-- --:--:-- 11658
$ curl --head -H "Authorization: Bearer $TOKEN"
HTTP/1.1 200 OK
content-length: 2782
content-type: application/vnd.docker.distribution.manifest.v1+prettyjws
docker-content-digest: sha256:767a3815c34823b355bed31760d5fb3daca0aec2ce15b217c9cd83229e0e2020
docker-distribution-api-version: registry/2.0
etag: "sha256:767a3815c34823b355bed31760d5fb3daca0aec2ce15b217c9cd83229e0e2020"
date: Wed, 16 Feb 2022 21:33:50 GMT
strict-transport-security: max-age=31536000
ratelimit-limit: 200;w=21600
ratelimit-remaining: 200;w=21600
docker-ratelimit-source: b535072a-ca47-4906-b50d-8be72dbb62e9

However, when I run the pull command, I get the rate-limit error.

$ docker pull hello-world
Using default tag: latest
Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading:

According to docker pull --help, the is no option for authentication. So, I wonder how can I pass credentials to the pull (or build) command?

docker login
1 Like