docker_practice/install/mirror.md
2020-10-26 16:35:34 +08:00

2.9 KiB

Mirror Accelerators

You may have difficulty pulling images from Docker Hub if you are in China. To resolve this issue, you may configure mirror accelerators. There are many cloud service providers that provide accelerators in China, for example,

Since some mirror services may be down sometimes, it is recommended to configure multiple mirrors simultaneously.

Most of the cloud service giants in China provide Docker image acceleration services, you can choose acceleration services based on which platform you are running Docker on. For more detailed information, you may refer to their official documents.

We take Azure China Mirrors https://dockerhub.azk8s.cn as an example to introduce more.

Ubuntu 16.04+、Debian 8+、CentOS 7

For Operating Systems using systemd, please write the following contents inside /etc/docker/daemon.json. And if the file does not exist, please create the file.

{
  "registry-mirrors": [
    "https://dockerhub.azk8s.cn",
    "https://reg-mirror.qiniu.com"
  ]
}

Note, make sure the file is in valid json format, otherwise Docker will be unable to start.

Then restart the service.

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

Note: if you refered to the old tutorial previously, and modified the content of docker.service, please remove the added contents(--registry-mirror=https://dockerhub.azk8s.cn).

Windows 10

For windows 10, choose Settings in the list after click on the Docker icon at the right-bottom of the desktop. Then choose Daemon, and inside the Registry mirrors, fill in https://dockerhub.azk8s.cn. And finally click Apply to save and apply the changes.

macOS

For macOS users, click Docker Desktop icon at the task bar -> Perferences... -> Daemon -> Registry mirrors. Then fill in the accelerator address https://dockerhub.azk8s.cn in the list. After the modification, click on Apply & Restart button, Docker will restart and apply the new mirror address.

Verify the Accelerator

After executing $docker info, if you can see the following result, you have successfully configured it.

Registry Mirrors:
 https://dockerhub.azk8s.cn/

gcr.io Mirror

In China, we cannot fetch gcr.io/* mirrors direclty, but we can replace gcr.io/<repo-name>/<image-name>:<version> with gcr.azk8s.cn/<repo-name>/<image-name>:<version>, for example

# $ docker pull gcr.io/google_containers/hyperkube-amd64:v1.9.2

$ docker pull gcr.azk8s.cn/google_containers/hyperkube-amd64:v1.9.2