The official Docker warehouse is located in a foreign server. Due to unexplicable reasons, the speed of extracting the image is very slow when we use the Docker pull command. Fortunately, we can use the accelerator provided by the domestic service provider for acceleration, which is an IP address in fact, and add it to the configuration file of Docker service. Can be implemented. This article describes the process.
Stop the Docker service
Execute command:
service docker stop
Copy the code
Modify the daemon.json file
Use the following command to create daemon.json file.
vim /etc/docker/daemon.json
Copy the code
The content of the file is as follows:
{
"registry-mirrors": [
"https://a8qh6yqv.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com"
]
}
Copy the code
The JSON format requires that the last item should not have a comma. Note: If using SecureCRT, you can paste the above content directly with the mouse after entering vim command I. There is no need to manually enter one by one. You can also run the following commands on the CLI:
cat > /etc/docker/daemon.json <<-EOF
{
"registry-mirrors": [
"https://a8qh6yqv.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com"
]
}
EOF
Copy the code
Modify the cgroup driver example incidentally:
cat > /etc/docker/daemon.json <<-EOF
{
"registry-mirrors": [
"https://a8qh6yqv.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com"
],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
Copy the code
Examples with Nvidia:
{
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
},
"registry-mirrors": [
"https://a8qh6yqv.mirror.aliyuncs.com"
]
}
Copy the code
Restart the Dokcer service
The command is as follows:
service docker start
Copy the code
test
To test the speed, use docker pull as follows:
docker pull latelee/busybox
Copy the code
You can see a significant increase in speed.
This article uses the accelerator for the author ali cloud image accelerator address, Ali cloud image market is currently provided for free, registered Ali cloud can be opened, support public or private mirror, is a good choice.