添加镜像源地址

list registry_mirrors 'https://docker.1ms.run'
list registry_mirrors 'https://docker.mirrors.ustc.edu.cn'
list registry_mirrors 'https://dockerproxy.com'

不同于debian的/etc/docker/daemon.json,istoreos(openwrt)的docker镜像加速源在这个位置/etc/config/dockerd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# The following settings require a restart of docker to take full effect, A reload will only have partial or no effect:
# log_driver
# bip
# blocked_interfaces
# extra_iptables_args
# device

config globals 'globals'
# option alt_config_file '/etc/docker/daemon.json'
option data_root '/opt/docker/'
# option log_driver 'local'
option log_level 'warn'
option iptables '1'
# list hosts 'unix:///var/run/docker.sock'
# option bip '172.18.0.1/24'
# option fixed_cidr '172.17.0.0/16'
# option fixed_cidr_v6 'fc00:1::/80'
# option ipv6 '1'
# option ip '::ffff:0.0.0.0'
# list dns '172.17.0.1'
# list registry_mirrors 'https://<my-docker-mirror-host>'
# list registry_mirrors 'https://hub.docker.com'
list registry_mirrors 'https://docker.1ms.run'
list registry_mirrors 'https://docker.mirrors.ustc.edu.cn'
list registry_mirrors 'https://dockerproxy.com'

# If your organization uses a proxy server to connect to the internet, you may need to configure the proxy.
# See https://docs.docker.com/engine/daemon/proxy/ for more details
config proxies 'proxies'
# option http_proxy 'http://proxy.example.com:3128'
# option https_proxy 'https://proxy.example.com:3129'
# option no_proxy '*.test.example.com,.example.org,127.0.0.0/8'

# Docker doesn't work well out of the box with fw4. This is because Docker relies on a compatibility layer that
# naively translates iptables rules. For the best compatibility replace the following dependencies:
# `firewall4` -> `firewall`
# `iptables-nft` -> `iptables-legacy`
# `ip6tables-nft` -> `ip6tables-legacy`

# Docker undermines the fw3 rules. By default all external source IPs are allowed to connect to the Docker host.
# See https://docs.docker.com/network/iptables/ for more details.

# firewall config changes are only additive i.e firewall will need to be restarted first to clear old changes,
# then docker restarted to load in new changes.
config firewall 'firewall'
option device 'docker0'
list blocked_interfaces 'wan'
# option extra_iptables_args '--match conntrack ! --ctstate RELATED,ESTABLISHED' # allow outbound connections

重启 Docker 服务

修改 UCI 配置文件后,必须重启服务才能使更改生效:

1
/etc/init.d/dockerd restart

最终验证

重启服务后,再次运行 docker info 来确认镜像加速器是否已被加载。

1
docker info | grep "Registry Mirrors" -A 5

如果配置成功,您现在应该能在输出中看到您配置的镜像地址列表:

1
2
3
4
Registry Mirrors:
https://docker.1ms.run
https://docker.mirrors.ustc.edu.cn
https://dockerproxy.com