docker_practice/install/mirror.md

64 lines
2.9 KiB
Go
Raw Permalink Normal View History

2020-10-26 08:35:34 +00:00
## Mirror Accelerators
2020-10-26 08:35:34 +00:00
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,
2020-10-26 08:35:34 +00:00
* [Azure China Mirrors `https://dockerhub.azk8s.cn`](https://github.com/Azure/container-service-for-azure-china/blob/master/aks/README.md#22-container-registry-proxy)
* [Alibaba Cloud Accelerator(Login Required)](https://cr.console.aliyun.com/cn-hangzhou/mirrors)
* [Qiniu Cloud Accelerator `https://reg-mirror.qiniu.com`](https://kirk-enterprise.github.io/hub-docs/#/user-guide/mirror)
2020-10-26 08:35:34 +00:00
> Since some mirror services may be down sometimes, it is recommended to configure multiple mirrors simultaneously.
2018-06-28 03:15:25 +00:00
2020-10-26 08:35:34 +00:00
> 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.
2018-07-10 00:07:31 +00:00
### Ubuntu 16.04+Debian 8+CentOS 7
2020-10-26 08:35:34 +00:00
For Operating Systems using [systemd](https://www.freedesktop.org/wiki/Software/systemd/), please write the following contents inside `/etc/docker/daemon.json`. And if the file does not exist, please create the file.
```json
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"
]
}
```
2020-10-26 08:35:34 +00:00
> Note, make sure the file is in valid json format, otherwise Docker will be unable to start.
2020-10-26 08:35:34 +00:00
Then restart the service.
```bash
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
```
2020-10-26 08:35:34 +00:00
> 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
2020-10-26 08:35:34 +00:00
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
2020-10-26 08:35:34 +00:00
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.
2020-10-26 08:35:34 +00:00
### Verify the Accelerator
2020-10-26 08:35:34 +00:00
After executing `$docker info`, if you can see the following result, you have successfully configured it.
```bash
Registry Mirrors:
https://dockerhub.azk8s.cn/
```
2020-10-26 08:35:34 +00:00
### gcr.io Mirror
2020-10-26 08:35:34 +00:00
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
```bash
2019-08-31 10:35:14 +00:00
# $ docker pull gcr.io/google_containers/hyperkube-amd64:v1.9.2
2019-08-31 10:35:14 +00:00
$ docker pull gcr.azk8s.cn/google_containers/hyperkube-amd64:v1.9.2
2020-10-26 08:35:34 +00:00
```