Practice of accelerating docker image configuration

Time:2022-1-5

Due to network reasons, the speed of our personal computers and servers pulling images from docker’s official warehouse is very slow, and timeout often occurs. To download without timeout and fast, you need to configure a flying accelerator.

Practice of accelerating docker image configuration

At present, many manufacturers provide accelerators. Here, take Alibaba cloud as an example to demonstrate how to obtain their own image accelerator and make the accelerator effective by configuring docker.

Get your own image accelerator

The official image acceleration service provided by Alibaba cloud opens the Alibaba cloud container image acceleration service pagehttps://help.aliyun.com/docum…

Practice of accelerating docker image configuration

According to the instructions on the page, we need to open the container image service console after logging in to alicloud (if there is no account, register one).

Open the container image service console and click the icon below the menu bar on the leftMirror acceleratorOption, click to display the corresponding content on the right.

Practice of accelerating docker image configuration

Listed at the top rightAccelerator addressThis is the goal of our operation. After we get this link, we can configure the docker.

Configure mirror accelerator

Ubuntu/Centos

Ubuntu and CentOS are one of the most widely used operating systems. Since they are both Linux, the specific operations are the same. First open/etc/docker/daemon.jsonFile, if not, create one, and then write the accelerator address just obtained to thedaemon.jsonIn the file:

{
  "registry-mirrors": ["https://c5uvansenbu.mirror.aliyuncs.com"]
}

Then, use the command to let docker load the new configuration and restart the docker service. The specific command is:

sudo systemctl daemon-reload
sudo systemctl restart docker

At this point, the docker image is accelerated.

MacOS

MacOS has launched two docker applications. Users with MacOS version less than 10.10.3 install docker toolbox. On the contrary, they install docker for Mac applications. We should know which one our applications are.

If you are the user installing docker toolbox, create a Linux virtual machine with docker environment installed through the following command, specify the machine name as default, and configure the accelerator:

docker-machine create --engine-registry-mirror=https://c5uvansenbu.mirror.aliyuncs.com -d virtualbox default

Then view the environment configuration of the machine, configure it locally, and access the docker service through the docker client:

docker-machine env default
eval "$(docker-machine env default)"
docker info

If you are a user who has docker for Mac installed, you can operate on the visual interface of docker application. Click the docker desktop application icon in the top bar, then select the options in the pop-up menu bar, and then click docker engine in the pop-up panel

Click and edit the JSON file in the corresponding input box on the right to add the accelerator link to theregistry-mirrorsIn the array, clickApplay & RestartButton. After the docker is restarted, the image acceleration will take effect.

Windows

Docker has also launched two applications for Windows systems. Windows10 corresponds to docker for windows, and other versions of windows correspond to docker toolbox.

The specific operation of toolbox application is the same as that of toolbox under MacOS. Create a Linux virtual machine with docker environment installed, specify the name and configure the accelerator address:

docker-machine create --engine-registry-mirror=https://c5uvansenbu.mirror.aliyuncs.com -d virtualbox default

Then view the environment configuration of the machine, configure it locally, and access the docker service through the docker client:

docker-machine env default
eval "$(docker-machine env default)"
docker info

The specific configuration of docker for windows is the same as that of docker for Mac. Configure the accelerator address through the visual interface, and finally restart docker. The specific operation is to right-click the docker tray small icon at the bottom right of the screen and select

Settings, select docker Daemon in the pop-up window, and then modify it in the edit windowregistry-mirrorsConfigure the corresponding accelerator address. Remember to restart after changing!

The article was first published inWei Shidong’s technical column http://www.weishidong.com/blo…

After the accelerator is configured, the speed of pulling the official image of docker is the same as that of opening the VIP, whoosh ~