Skip to content

Speeding up Docker Downloads in China

Introduction

If you are located in mainland China, you might have a hard time pulling docker images, however, you can speed things up by using the Docker Mirror hosted by USTC.

Configure Docker Daemon

You can configure the Docker daemon using a JSON file. Usually it's located at /etc/docker/daemon.json; if it doesn't exist create a new one. Then, add "https://docker.mirrors.ustc.edu.cn/" to the registry-mirrors array to pull from the USTC registry mirror by default.

After editing, your /etc/docker/daemon.json should look like this:

{
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    },
    "default-runtime": "nvidia",
    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}

You can ignore the runtime configurations if you don't have an Nvidia GPU or you don't want to enable hardware acceleration.

Then restart dockerd:

sudo systemctl restart docker

Verify Default Registry Mirror

You can verify your changes by:

docker info

If you see the following lines, you have configured your Docker daemon successfully.

Registry Mirrors:
    https://docker.mirrors.ustc.edu.cn/