Allow specify registry-mirrors or proxies in `/etc/docker/daemon.json`

Problem/Justification
The Chinese government blocks access to Docker Hub, you may find articles like Chinese Docker Hub Complete Shutdown: How Far Can Kubernetes Image Repositories Go? | by Mr.PlanB | Medium . TrueNAS Apps are affected and Chinese users cannot install/update any app.

Possible solutions

To ‘fix’ the networking issue, Chinese people find a way to set up self-hosted Docker Hub mirrors, they have to specify registry-mirrors in /etc/docker/daemon.json , this file is managed by TrueNAS middleware.

Example content in daemon.json:

{
  "registry-mirrors": ["https://docker.example.mirror.io"]
}

There is another way to workaround the networking issue, please provide Docker daemon proxy configuration entries, the detailed configuration is described in Daemon proxy configuration | Docker Docs

4 Likes

Truenas Scale uses Rancher K3S as its container solution. To resolve the issue, you can refer to the following documentation:
k3s-private-registry
and
k3s-registry-mirror

Currently. With the release of Electric Eel, which I understand is scheduled for 1 October, this will cease to be the case, and they’ll use Docker instead. Which some people apparently think is an improvement for some reason.

For me personally, I’m familiar with both K8s and Docker, and the solutions for this issue are pretty similar. But it’s true that more users are familiar with Docker rather than containerd, so lowering the learning curve for users is definitely a good thing.

Still a valid issue as of 24.10.2.
Also, certain authoritarian dictatorial governments in Eastern Europe are blocking docker too now.
Currently you can’t even modify daemon.json yourself manually, anything you put in it yourself will be overwritten after a reboot.

I believe you can do this now in UI in Fangtooth

In fangtooth,i can’t edit the daemon.json,if input this code:

{
  "registry-mirrors": ["https://docker.example.mirror.io"]
}

and restart the truenas,this file will be restored.
how can I solve this problem?
please help me~

truenas overwrites changes to sytem files like the daemon.json on reboot. This is by design and can’t be changed.

I see two options for you:
Either vote for this Feature Request and wait to see if iXsystems accepts it or add a post-init script that edits the file in question post every boot.

Is there any further update to this problem? I suffer from exactly the same issue also being in China, although weirdly some docker sites are more accessible than others. I currently have two apps that refuse to go “Up” after update although the update itself appears to work. Also DockGe will not install at this time. It would be really good if the option of adding alternative mirrors became part of the system. I tried adding mirror IP addresses in the etc/hosts file but that made no difference. I was told elsewhere in this forum that adding the mirror repository address whilst installing an app as a Custom app - but so far not successful either. Currently basically means any location with network issues to docker hub will have the same problem. Does anyone have a guide to the right way to add mirror repository addresses to the Custom app install as perhaps i am doing something wrong? Thanks.

At the weekend I tried raising a bug ticket but that response, yesterday, was terse and unhelpful. I was hoping for a bit more guidance than “you seem to be having trouble connecting to docker hub”

By accident I discovered this online instruction from TrueNAS: Initial Setup | TrueNAS Apps Market Configuring Registry Mirrors… But the referred items do not exist on my TrueNAS Scale (25.4.02) So yet more frustration as this saga continues.

Wait - I just saw the announcement for 25.10.1 Beta - looks like the function may be added in there.
image