How to Use a Pull-Through Cache Registry in CI
A pull-through cache mirror serves base images from a nearby cache, sparing you Docker Hub rate limits.
Point BuildKit at a registry mirror using a buildkitd.toml config passed to docker/setup-buildx-action. Pulls of cached images are served from the mirror.
Steps
- Stand up a pull-through cache (for example a registry running in mirror mode).
- Create a
buildkitd.tomlthat lists the mirror under[registry."docker.io"]. - Pass it via
buildkitd-configondocker/setup-buildx-action.
buildkitd config
buildkitd.toml
[registry."docker.io"]
mirrors = ["mirror.internal.example.com"]
[registry."mirror.internal.example.com"]
http = falseWorkflow
.github/workflows/ci.yml
steps:
- uses: docker/setup-buildx-action@v3
with:
buildkitd-config: ./buildkitd.tomlGotchas
- A mirror caches public images; private images still authenticate against the upstream.
- Mirrors reduce pulls but do not remove the need for authenticated pulls on Docker Hub.
Related guides
How to Avoid Docker Hub Rate Limits in CIAvoid Docker Hub anonymous pull rate limits in GitHub Actions by authenticating every pull with docker/login-…
How to Cache Build Layers to a Registry in CISpeed up Docker builds in GitHub Actions by exporting BuildKit layer cache to a registry with cache-to and ca…