Docker Image Acceleration
Sometimes, pulling images from DockerHub in China can be challenging, and in such cases, configuring an image accelerator can be helpful. Both Docker's official services and many domestic cloud service providers offer accelerators in China, such as:
- USTC Mirror: https://docker.mirrors.ustc.edu.cn/
- NetEase: https://hub-mirror.c.163.com/
- Alibaba Cloud: https://<yourID>.mirror.aliyuncs.com
- Qiniu Cloud Accelerator: https://reg-mirror.qiniu.com
After configuring an accelerator address, if you find that images cannot be pulled, please switch to another accelerator address. Major domestic cloud service providers offer Docker image acceleration services. It is recommended to choose the corresponding image acceleration service based on the cloud platform where Docker is running.
Alibaba Cloud image retrieval address: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors. After logging in, select Image Accelerator from the left menu to see your personalized address.
Previously, there was a Docker official accelerator https://registry.docker-cn.com, but it seems to be no longer usable. We can add several domestic mirrors, and if one is not usable, we will switch to another that is functional to pull images.
Ubuntu14.04, Debian7Wheezy
For systems using upstart, edit the /etc/default/docker file and configure the accelerator address in DOCKER_OPTS:
DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com"
Restart the service:
$ sudo service docker restart
Ubuntu16.04+, Debian8+, CentOS7
For systems using systemd, please write the following content in /etc/docker/daemon.json (create the file if it does not exist):
{"registry-mirrors":["https://reg-mirror.qiniu.com/"]}
Then restart the service:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
Windows 10
For systems using Windows 10, right-click the Docker icon in the system tray and select Settings from the menu. In the configuration window, select Daemon from the left navigation menu. Fill in the accelerator address https://docker.mirrors.ustc.edu.cn/ in the Registry mirrors section, then click Apply to save. Docker will restart and apply the configured image address.
Mac OS X
For Mac OS X users, click the Docker for Mac application icon in the taskbar -> Preferences... -> Daemon -> Registry mirrors. Enter the accelerator address https://reg-mirror.qiniu.com in the list. After modifying, click Apply & Restart, and Docker will restart and apply the configured image address.
Checking if the Accelerator is Effective
After configuring the accelerator, if image pulling is still very slow, manually check if the accelerator configuration is effective. Execute docker info
in the command line. If you see the following content in the results, the configuration is successful:
$ docker info
Registry Mirrors:
https://reg-mirror.qiniu.com