Why does this happen, when I want to build an image from a Dockerfile in CodeCommit with CodeBuild?
I get this Error:
toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
Try not to pull the images from the docker hub because docker has throttling for pulling the images.
Use ECR(Elastic Container Registry) for private images and Amazon ECR Public Gallery for public docker images. Advice for customers dealing with Docker Hub rate limits, and a Coming Soon announcement for the advice from AWS for handling this.
In my case, there was NO issue with Docker login.
I was able to download docker images with docker pull nginx.
However when I was trying to create a k8s pod with the above image, I was getting this error:
you have reached your pull rate limit. You may increase the limit by authenticating and upgrading
This is how I managed to fix this issue by creating a private docker registry :
create and run a private docker registry
docker run -d -p 5000:5000 --restart=always --name registry registry:2
download nginx image from public docker hub
docker pull nginx
create a tag for nginx before pushing it to private registry
docker tag nginx localhost:5000/nginx
Push to registry
docker push localhost:5000/nginx
And finally created a Pod successfully and also got rid of this issue.
If you run docker pull _____ on the machine once, on subsequent times your Dockerfile is run, it will use the local copy instead of hitting Docker Hub (and using up your rate limit). So for me I ran this command one-time:
docker pull ubuntu:18.04
... and subsequent times it worked fine.
Alternatively, switching to the AWS public Docker repository by switching my Dockerfile from:
FROM ubuntu:18.04
to
FROM public.ecr.aws/lts/ubuntu:latest
also worked for me.
If Amazon ECR Public Gallery does not offer the desired image copying the image from Docker Hub to a private ECR registry could also be an option.
Skopeo for example can do this. This snippet synchronizes your private registry with Docker Hub:
skopeo sync --dest-creds AWS:$(aws ecr get-login-password --output text) --src docker --dest docker docker.io/library/nginx <YourAWSAccountId>.dkr.ecr.eu-central-1.amazonaws.com/
One solution is that you should login docker hub by below command:
$ sudo docker login --username=yourUsername
Password:
WARNING: login credentials saved in C:\Users\sven\.docker\config.json
Login Succeeded