Docker Hub: Error 429 too many requests

One day, I realized that one of my CodePipeline was failed to build the docker image. I investigated what caused the error. And then, I found out the following error message when executing docker build command.

1ERROR: failed to copy: httpReaderSeeker: failed open: unexpected status code https://registry-1.docker.io/v2/library/php/manifests/sha256:7b1cd0d9e1922e96ad3bc9fc44880cf7247f5a22a4badfd25480bf759edf2804: 429 Too Many Requests - Server message: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

I remembered the news which I read before that Docker Hub got started to set some limits and I checked the link which is included in the above error.

Understanding Docker Hub Rate Limiting

However, I was confused because I’m working for a very small start-up company and the CodePipeline runs a few times a day so I couldn’t understand why I reached the limit. Then, I came out that it may be "docker login" is necessary because the CodePipeline environment is shared servers so anonymous access was added up together. So, I got a new log-in account for building image and added the following command before docker build command in the buildspec in the CodePipeline and then I solved the problem.

1docker login -u hoge-hoge -p fuga