How to configure the official domestic acceleration mirror for Docker

  • 2020-06-15 10:43:16
  • OfStack

Visiting the official mirror image of Docker in China, 1 has been running at a snail's pace. In order to quickly access the official image of Docker, 3-way accelerators are configured. Currently, 3-way accelerators are commonly used: netease, USTC, DaoCloud and aliyun.

Now Docker has officially launched a mirror acceleration service for China. With Docker official image acceleration, domestic users can access the most popular Docker images with faster download speeds and greater stability.

How do I use official mirroring

The Official China image acceleration is available via ES15en.docker-ES17en.com. Currently the mirror library contains only popular public images, while private images still need to be pulled from the US mirror library.

You can pull directly from the image acceleration address using the following command.


$ docker pull registry.docker-cn.com/myname/myrepo:mytag

Such as:


$ docker pull registry.docker-cn.com/library/ubuntu:16.04

Note: Unless you modify the registry-ES29en parameters for the Docker daemon, you will need to fully specify the name of the official mirror. For example, library/ubuntu, library/redis, library/nginx.

Configure the accelerator for the Docker daemon

Docker daemon is configured to use Docker official image acceleration by default. You can configure the ES44en-ES45en parameter when the Docker daemon starts.

Start Docker from the command line


$ docker --registry-mirror=https://registry.docker-cn.com daemon

Start Docker from the configuration file

The Docker version is 1.12 or higher

Modify/etc/docker/daemon json registry - mirrors key on the file, and add value.


$ vim /etc/docker/daemon.json

{
 "registry-mirrors": ["https://registry.docker-cn.com"]
}

Versions of Docker are between 1.8 and 1.11

You can find the Docker profile in which DOCKER_OPTS is added. Different Linux distributions have different configuration paths, for example Ubuntu.

a) Ubuntu 14.04

Modify the /etc/default/docker file to add the following parameters.


$ vim /etc/default/docker

DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com"

b) Ubuntu 15.04 later

Ubuntu 15.04 USES Systemd management service by default, with a slightly different accelerator configuration. Add the boot parameters to the Systemd service file.


$ vim /lib/systemd/system/docker.service

[Service]

ExecStart=/usr/bin/docker -d -H fd:// --registry-mirror=https://registry.docker-cn.com

After the changes have been saved, restart Docker for the configuration to take effect.


$ service docker restart

When the Docker daemon is configured with an accelerator, the image can be pulled by default via the official image acceleration without specifying registry.docker-cn.com on each pull.


Related articles: