Why?
You get this error when you try to pull an image from the public Docker Hub repository after you have reached your Docker pull rate limit. Docker Hub uses IP addresses to authenticate the users, and pull rates limits are based on individual IP addresses.
- For anonymous users, the rate limit is set to 100 pulls per 6 hours per IP address.
- For authenticated users with a Docker ID, the pull rate is set to 200 pulls per 6-hour period.
- If your image pull request exceeds these limits, these requests are denied until the six-hour window elapses.
Every docker pull command execution counts against your quota regardless if the requested image is up to date or not. Hitting the request limit is a piece of cake if you deploy your application stack to a cluster.
Solutions:
1. Use Amazon ECR public registry for public container images
You can avoid reaching the Docker Hub's rate limit by pulling images from the Amazon ECR public registry.
The Amazon ECR public registry contains popular base images, including operating systems, AWS-published image.
For E.g.
FROM public.ecr.aws/lts/ubuntu:latest
2. Subscribe to Docker Hub
This will allow you to increase the pull limit for authenticated users and make it unlimited for anonymous ones. If you are an individual or a small team of 2-10 people who just need a space to store images, then paying $5 to $7/month per user is the simplest solution.
3. Mirror Images to Your Own Registry
Mirroring or copying images from Docker Hub to your own registry might seem like overkill at first glance. However, it has two major benefits for security and governance and is considered a best practice, especially for using containers in an enterprise context.
4. Proxy to Docker Hub
This option is pretty similar to option #3 but there are no replication rules needed. Yet you get the same benefits of security and governance. In this scenario, you create a so-called proxy cache project that will store your last used images automatically. They can be later pulled from the proxy cache without touching the Docker Hub limit.
Workaround (Worked for me)
5. Copy public images into an Amazon ECR private registry
Create an Amazon Elastic Container Registry (Amazon ECR) repository, and then push the image into this new repository. With this approach, you might avoid exceeding the Docker Hub pull limit by pulling the images from the Amazon ECR repository.
Then, I replaced following line in Dockerfile
FROM python:3.7
with
ARG REPO=655606377847.dkr.ecr.us-west-2.amazonaws.com
FROM ${REPO}/python:3.7
P.S. I tagged python image with 3.7 instead of latest(default)
For more details -