SoFunction
Updated on 2025-04-13

Two ways to configure mirror accelerator for docker

Method 1: Configure the mirror accelerator globally (recommended)

Modify Docker's configuration file so that all image pull requests pass through the USTC mirroring station by default.

step:

Create or modify Docker configuration files:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/ <<EOF
{
  "registry-mirrors": [""]
}
EOF

Restart Docker service:

sudo systemctl restart docker

Verify that the configuration is effective:

docker info | grep "Registry Mirrors"

The output should contain:

Registry Mirrors:
  /

Method 2: Specify the mirror source when pulling a single image

If you only need to temporarily pull a mirror from the USTC mirror site, you can use--registry-mirrorParameter specification (requires support from Docker client).

step:

docker pull --registry-mirror= nginx:latest

Verify the image download source

When pulling the image, observe whether the domain name downloaded by the mirror layer comes from

docker pull nginx:latest

In the output log, the mirror layer URL should be displayed as:

/v2/library/nginx/blobs/...

Frequently Asked Questions

1. The configuration is not effective

• make sureThe file path is correct and there are no syntax errors.
• Check whether the Docker service restarts successfully:

systemctl status docker

2. Mirror accelerator priority

• If multiple mirror sources are configured (such as using Alibaba Cloud and USTC at the same time), Docker will try to pull in order.

3. The mirror site is not available

• If the USTC mirroring station is not accessible, it can be replaced with another domestic mirroring source:

"registry-mirrors": [
  "",
  ""
]

Through the above configuration, Docker will give priority to downloading images from the China University of Science and Technology mirror site, significantly improving the pulling speed of domestic users.

This is the end of this article about the two ways to configure the mirror accelerator of docker. For more related content on the docker configuration image accelerator, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!