Cache Docker Hub Images with Azure Container Registry
Describes how to configure artifact cache in Azure Container Registry, map Docker Hub and GHCR images to a private ACR namespace, and pull them with the Docker…
This post explains how to use ACR (Azure Container Registry) to cache images from Docker Hub and GitHub Container Registry.
Detailed steps #
- Sign in to the Azure portal
- Create a resource
- Search for Container Registry and create one
- For users in mainland China, East Asia (Hong Kong), Southeast Asia (Singapore), or Japan East are recommended; otherwise, choose any region as needed
- Open the Container Registry you created
- Expand Services on the left, then click Cache
- Create rule and configure the rule
- Rule name: dockerio
- Source: Docker Hub
- Repository path:
docker.io/* - New ACR repository namespace:
dockerio/*
- Configure other sources as needed, for example
ghcr.io/*->ghcrio/* - If you are using it within an Azure environment, or you can sign in with Azure CLI, for example
az acr login, then you do not need to set up the Token below. Go directly to Access Control (IAM) and configure the permission (AcrPull) - Expand Repository permissions on the left, then click Token
- Click Add. For Token (name), enter a name you can identify, and select
_repositories_pullfor Scope - Click Actions to the right of password1 to generate a Token for use. It will also provide a command for signing in to ACR with the Docker client. Be sure to remember this password; after you close it, you will not be able to see it again
Image replacement #
After everything is configured and your Docker client has signed in, replace image names according to the rules you configured. For example, using the rules above:
library/redis:6.2->xxxxx.azurecr.io/dockerio/library/redis:6.2tensorchord/pgvecto-rs:pg14-v0.2.0->xxxxx.azurecr.io/dockerio/tensorchord/pgvecto-rs:pg14-v0.2.0