Mirror Docker Images to Alibaba Cloud with GitHub Actions – A Free, Fast Solution
This guide explains how to use GitHub Actions to automatically mirror Docker images from public registries to an Alibaba Cloud private registry, providing step‑by‑step configuration of the cloud namespace, GitHub secrets, and the action workflow to keep images accessible within China.
Background
Since July 2024, developers in mainland China cannot pull images from Docker's official registry, and many domestic mirrors are also inaccessible, causing significant inconvenience for software development.
Solution Overview
The method uses GitHub Actions to copy images from foreign Docker registries (DockerHub, gcr.io, k8s.io, ghcr.io, etc.) into an Alibaba Cloud private registry, providing fast access for domestic servers.
Key Features
Supports any Docker registry such as DockerHub, gcr.io, k8s.io, ghcr.io.
Handles large images up to 40 GB.
Uses Alibaba Cloud's official network for high speed.
Customizable image list via images.txt.
Step 1 – Configure Alibaba Cloud Registry
Log in to the Alibaba Cloud Container Registry console at https://cr.console.aliyun.com/, create a namespace, and set a fixed password. After setting the password, you can log in locally with docker login.
Step 2 – Set GitHub Action Secrets
Create four repository secrets in GitHub using the information obtained in Step 1. Example values:
- ALIYUN_REGISTRY: registry.cn-chengdu.aliyuncs.com <changeme>
- ALIYUN_NAME_SPACE: flyeric <changeme>
- ALIYUN_REGISTRY_USER: amuguelove1991 <changeme>
- ALIYUN_REGISTRY_PASSWORD: xxx <changeme>Step 3 – Obtain the Source Code
The project flyeric0212/docker-image-mirror is hosted on GitHub at https://github.com/flyeric0212/docker-image-mirror. Fork the repository and edit the images.txt file to list the Docker images you want to mirror.
Step 4 – Run the GitHub Action
Add the desired image names and tags to images.txt, commit the changes, and the GitHub Action will automatically build and push the images to the Alibaba Cloud registry.
Step 5 – Verify Images in Alibaba Cloud
After synchronization, view the list of images and their tags in the Alibaba Cloud console, then pull them directly with docker pull after logging in to the registry.
Reference
[1]flyeric0212/aliyun-docker-image-mirror (GitHub): https://github.com/flyeric0212/aliyun-docker-image-mirror
Eric Tech Circle
Backend team lead & architect with 10+ years experience, full‑stack engineer, sharing insights and solo development practice.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
