Home >Operation and Maintenance >Docker >How to change the domestic image source in docker

How to change the domestic image source in docker

王林
王林forward
2020-08-25 16:59:0216390browse

How to change the domestic image source in docker

Reason for change

Accessing the official Docker image in China has always been as slow as a snail. In order to quickly access the Docker official image, a third-party accelerator will be configured. Currently, the commonly used three-party accelerators are: NetEase, USTC, DaoCloud, and Alibaba Cloud.

(Recommended tutorial: docker tutorial)

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

How to use the official image?

Docker China’s official image acceleration can be accessed through registry.docker-cn.com. Currently, the mirror library only contains popular public images, while private images still need to be pulled from the US mirror library.

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

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

An example is as follows:

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

Note: Unless you modify the --registry-mirror parameter of 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 process

Start Docker through the configuration file, modify the /etc/docker/daemon.json file and add the registry-mirrors key value.

sudo vim /etc/docker/daemon.json
{
 "registry-mirrors": ["https://registry.docker-cn.com"]
}

You can also choose NetEase’s mirror address: http://hub-mirror.c.163.com

{
“registry-mirrors”: [“http://hub-mirror.c.163.com”]
}

After saving the modification, restart Docker to make the configuration take effect.

sudo service docker restart

Then the speed went up to a higher level.

The above is the detailed content of How to change the domestic image source in docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete