This website provides Linux server operation and maintenance, automated script writing and other services. If you need, please contact the blogger on WeChat: xiaozme
For some reasons, the official Docker Hub warehouse can no longer be pulled in China. If it is a domestic network environment, the domestic image can be configured for use, so as to solve the problem of Docker image pulling failure or slowness.
Configure Docker image source
If not /etc/docker/daemon.json
For this configuration file, you can directly use the following commands:
#Create Directory sudo mkdir -p /etc/docker #Write image configuration sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": [ " https://docker.m.daocloud.io ", " https://dockerproxy.com ", " https://docker.mirrors.ustc.edu.cn ", " https://docker.nju.edu.cn " ] } EOF #Restart the docker service sudo systemctl daemon-reload sudo systemctl restart docker
If it already exists /etc/docker/daemon.json
For this configuration file, manually copy the following image address and add it to the configuration:
"registry-mirrors": [ " https://docker.m.daocloud.io ", " https://dockerproxy.com ", " https://docker.mirrors.ustc.edu.cn ", " https://docker.nju.edu.cn " ]
Don't forget to restart the Docker service:
#Restart the docker service sudo systemctl daemon-reload sudo systemctl restart docker
Note: It is recommended to set more than 2 image addresses, because some images may not be updated in time, which may result in the failure to pull the latest tags, but it is not advisable to set too many images, otherwise the performance will be affected!
verification
input docker info
Command, you can see the "Registry Mirrors" address list, which indicates that the setting is successful, as shown in the following figure:
At this time, we can pull an image test randomly, such as:
#Pull Debian image docker pull debian
epilogue
The problem of Docker image pulling failure and slowness can be solved by setting domestic images of Docker Hub. It is recommended to set 2-4 image addresses. As time goes by, some image addresses may become invalid. If there is any problem, please leave a message for feedback!
This article refers to: Docker Hub Image Accelerator