pull through cache

Overview

This post shows how to bypass Docker Hub rate limit using Pull through cache.

Background

Docker Hub returns a 429 Too Many Requests error when you exceed the rate limit for image downloads.

Here is the pull rate limit for each user type:

User TypePull Rate Limit
Anonymous (not logged in)100 docker pull requests per 6 hours
Logged in account200 docker pull requests per 6 hours
Pro or higher (logged in)No limit

Here are some ways to avoid Docker Hub rate limit:

  1. Use imagePullSecret based on Kubernetes secrets to pull public images.
  2. Manually pull images and store them in Private ECR.
  3. Use Pull through cache to cache public images in Private ECR.
  4. Use Harbor's Proxy Cache to cache public images in Harbor.

From my experience with all these methods, Harbor Proxy is the most convenient and vendor-neutral. It doesn't lock you into a specific cloud, and if you already use Harbor, you just need to create a Proxy Cache project. This post covers option 3.

Setup

Before Pull Through Cache

I needed to pull 15 images for an Airbyte version upgrade.

I didn't know about Pull Through Cache at first. So I manually cached all 15 public images to Private ECR using this tedious workflow:

Manual workflow before using Pull Through Cache

After Pull Through Cache

With ECR's Pull Through Cache, you only need to run a single pull command. This makes caching multiple public images from different registries much easier and saves pull costs.

Private ECR repositories are created automatically and cache the public images. The best part is that it caches both the container image manifest and image files from public registries, so it works for all CPU architectures.

Simple workflow after using Pull Through Cache

You need to set up these ECR settings first:

Conclusion

Pull Through Cache simplifies caching public images to Private ECR. Once set up, just run a single pull command and ECR handles the rest. If you want to avoid vendor lock-in and run a self-hosted registry, consider Harbor Proxy Cache as an alternative.