Configure domestic mirroring in Docker

1. Why configure a domestic image for docker

  Under normal circumstances, docker has a foreign official image that is connected by default. It is not a problem for netizens in foreign countries to access the official image, but China is not foreign after all. Due to different national conditions, China's network access to foreign official images has always been very slow. And often encounter the dilemma of network disconnection, so if we want to use the docker image normally, then we have to configure the corresponding domestic image.

2. What are the available domestic mirrors

  There are many domestic mirrors that Docker can configure, such as: Alibaba Cloud, NetEase Honeycomb, DaoCloud, Docker China official mirror, etc. These are all good mirror warehouses that you can choose at will.

3. Configure Docker China official image

1. Introduction to the official image of Docker China

  In China, the official mirror library can be accessed through registry.docker-cn.com. At present, the mirror library only contains popular public mirrors, while private mirrors still need to be pulled from the US mirror library.

2. Configure Docker China official image

  Use vi to modify the /etc/docker/daemon.json file and add "registry-mirrors": [" https://registry.docker-cn.com "], as follows:

vi /etc/docker/daemon.json 

“registry-mirrors”: [“https://registry.docker-cn.com“] 
}

3. Restart Docker

  After configuration, execute the following command to make the docker configuration file take effect

systemctl daemon-reload 
systemctl restart docker

4. Results of the test configuration

1. Introduction to busybox

  We can test whether the mirror address is configured successfully by pulling the mirror from the mirror repository. For example, we can try to pull a simple busybox mirror for the corresponding test.

  busybox is a software that integrates more than 100 of the most commonly used linux commands and tools, and it is also a minimal Linux system. It provides the main functions of the system, such as grep, find, mount and telnet, but does not include some related GNU related functions and options.

2. Pull busybox

  The execution command is as follows:

docker pull busybox

  When you see the following information, the mirror has been pulled successfully

Using default tag: latest 
Trying to pull repository docker.io/library/busybox … 
latest: Pulling from docker.io/library/busybox 
9e87eff13613: Pull complete 
Digest: sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4

3. Test busybox

  Test the pulled busybox image

[root@localhost ~]# docker run busybox echo “hello world” 
hello world

  When we see "hello world" printed on the console, it means that our busybox has been tested successfully.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325807959&siteId=291194637