A few days ago, all major mirror sites went down, and pulling Docker images became a problem.
At first, I didn't care much and just used a proxy to pull the images. But even with the proxy, I couldn't pull them properly when using Docker locally.
So I started looking for solutions and found the following options:
- Build using Cloudflare Workers, which requires a domain -> Original Post
- Self-build Nexus 3, which requires a foreign VPS with at least 4GB of memory and a domain -> Original Post
- Use Github Action to transfer DockerHub images to Alibaba Cloud private repository, which only requires a Github account -> Original Post
- Use Nginx reverse proxy, which is more suitable for those who already have a server -> Original Post
- As for other options, there are ready-made image sources, but they are generally not very stable, so I didn't consider them.
I used the first option, which is relatively simple. The tutorial in the original post is not very detailed, so I will provide more information here.
- Go to the Cloudflare homepage, create a new Workers in the "Workers & Pages" section on the left, and save the "Account ID" on the right.
Give the Workers a name, click "Save", and then click "Finish".
Once this page appears, you can proceed to the next step.
-
Fork this repository and clone it to your local machine.
Install the dependencies first:
pnpm i
Then rename
wrangler.toml.sample
towrangler.toml
:cp wrangler.toml.sample wrangler.toml
Edit the
wrangler.toml
file and modify thename
andaccount_id
:name = "Name of the workers" account_id = "Paste the Account ID you copied earlier" main = "src/index.ts" workers_dev = true compatibility_date = "2024-06-08" kv_namespaces = [ { binding = "HAMMAL_CACHE", id = "your kv id" } ]
-
Get the
kv ID
by running the following command. It will output the ID, which you need to update in the configuration:npx wrangler kv:namespace create hammal_cache
-
Deploy by running:
pnpm run deploy
Warning
Here, you will be prompted that you are about to publish a Workers service. The last time this service was published was through the Cloudflare Dashboard. Any edits made through the Cloudflare Dashboard will be overwritten by your local code and configuration.
Enter
y
. Normally, a browser will open and ask for authorization. Grant the authorization. In my case, I have already deployed it, so it didn't pop up. -
Add a domain to the newly deployed Workers.
Wait for the domain to take effect, and then you can use it normally. Usually, on the server, you just need to modify/etc/docker/daemon.json
and configure the source address of your newly built mirror."registry-mirrors": [ "https://hammal.example.com" ]
On my Mac, I use Orbstack, so I need to configure it directly in the software.
This article is synchronized and updated to xLog by Mix Space.
The original link is https://remrin.dev/posts/dev/docker