that was really helpful, thanks very much!
here is the working script (tested on unRaid 6.8.2):
#!/bin/bash
#name=docker.registry_mirrors
# prepare folder
mkdir -p /etc/docker
# update mirror
tee /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
EOF
# restart docker service if necessary
is_docker_running=$(/etc/rc.d/rc.docker status | awk 'NR == 1 {print} ' | grep running)
echo $is_docker_running
if [ ! -z "$is_docker_running" ]; then
/etc/rc.d/rc.docker restart
fi