how can i change my docker Source Mirror


Recommended Posts

hi guys.i'm live in china ,so So I pull my docker mirror very, very slowly. i want set mirror  use the following command

mkdir -p /etc/docker

tee /etc/docker/daemon.json <<-'EOF'

{


"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]


}

EOF

Then I restart my docker servers,It works 100 times faster。

Now the problem is, once I restart the nas, the file /etc/docker/daemon.json , failed to save....i used  winscp to view the file. It doesn't exist

so ,Is there a kind person who can help me

 

Edited by galfordliu
Link to comment
5 hours ago, trurl said:

User Scripts plugin 

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

 

Edited by qgymib
  • Like 1
Link to comment
  • 10 months later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.