file

Official image acceleration

Due to the operator's network, you may pull the Docker Hub image slowly, or even fail to download it. To this end, the Alibaba Cloud container image service ACR provides an official image accelerator to speed up the download of official images.

important

The image accelerator is a service for individual developers. It is limited to supporting individual development scenarios and is not allowed to be re packaged or used commercially.

explain

According to Docker's policy, from November 1, 2020, it will gradually limit the rate and the number of pull requests to anonymous and free users of Docker Hub. The ACR image accelerator cannot guarantee that the latest image version will be pulled. It is recommended that you specify the image version to pull. For a detailed introduction to the Docker Hub pull request limit, see Download rate limit

Function change description

Change content

Since July 2, 2024, ACR has adjusted the use range of the image acceleration function:

  • Only Alibaba Cloud users can use this image acceleration capability on Alibaba Cloud products that support public network access.

  • Only container images within a limited range can be pulled through the image accelerator.

Recommended scheme

Due to unstable factors such as the operator's network, the image accelerator cannot ensure that the container image of the specified version is successfully pulled:

For more details, see [Product Change] ACR Image Accelerator Function Adjustment Announcement

Get the image accelerator address

ACR will generate an image accelerator address for each account (AliCloud account or RAM user). You need to obtain the image accelerator address before configuring the image accelerator.

Sign in Container Image Service Console , select from the left navigation bar Mirror tool > Image accelerator , on Image accelerator Page acquisition Accelerator address

 For example: Accelerator address: [system assignment prefix]. mirror.aliyuncs.com

Configure Docker runtime image accelerator

Under different operating systems, the way to configure the accelerator is slightly different. The following describes the configuration methods of the main operating systems.

When your Docker version is newer

When the Docker Version you downloaded and installed is no less than 1.10, it is recommended to configure it through daemon config. Use Profile /etc/docker/daemon.json (If not, create a new file).

 { "Registry mirrors": ["<image accelerator address>"] }

Then restart Docker Daemon.

When your Docker version is older

You need to modify the corresponding configuration file according to different operating systems.

  • Ubuntu 12.04 - 14.04

    The location of the Ubuntu configuration file is /etc/default/docker Directory. You only need to add the accelerator configuration item in this configuration file and restart Docker.

     echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=<your accelerate address>\"" | sudo tee -a /etc/default/docker sudo service docker restart
  • Ubuntu 15.04 - 15.10

    The location of the Ubuntu configuration file is /etc/systemd/system/docker.service.d/ Directory. Create an arbitrary *.conf The file can be used as the configuration file. Then add the accelerator configuration item to the configuration file, and restart the Docker.

     sudo mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/mirror.conf <<-'EOF' [Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// --registry-mirror=<your accelerate address> EOF sudo systemctl daemon-reload sudo systemctl restart docker
  • CentOS 7

    The configuration mode of CentOS is slightly complicated. You need to first set the default configuration file( /lib/systemd/system/docker.service )Copy to /etc/systemd/system/docker.service Then add the accelerator address to the startup command in the configuration file, and then restart Docker.

     sudo cp -n /lib/systemd/system/docker.service /etc/systemd/system/docker.service sudo sed -i "s|ExecStart=/usr/bin/docker daemon|ExecStart=/usr/bin/docker daemon --registry-mirror=<your accelerate address>|g" /etc/systemd/system/docker.service sudo sed -i "s|ExecStart=/usr/bin/dockerd|ExecStart=/usr/bin/dockerd --registry-mirror=<your accelerate address>|g" /etc/systemd/system/docker.service sudo systemctl daemon-reload sudo service docker restart
  • Redhat 7

    Red Hat 7 configuration accelerator, need to edit /etc/sysconfig/docker Configuration file. stay OPTIONS Add accelerator configuration in configuration item --registry-mirror=<your accelerate address> Final execution sudo service docker restart Command to restart Docker Daemon.

  • Redhat 6/CentOS 6

    Docker cannot be installed directly on these two systems. You need to upgrade the kernel.

    Need to edit when configuring accelerator /etc/sysconfig/docker Configuration file. stay other_args Add accelerator configuration in configuration item --registry-mirror=<your accelerate address> Final execution sudo service docker restart Command to restart Docker Daemon.

  • Docker Toolbox

    When using Docker Toolbox on Windows and Mac systems, it is recommended to configure the accelerator address when creating a Linux virtual machine.

     docker-machine create --engine-registry-mirror=<your accelerate address> -d virtualbox default docker-machine env default eval "$(docker-machine env default)" docker info

    If you have created a virtual machine through docker machine, you need to modify the configuration by logging in to the virtual machine.

    1. implement docker-machine ssh <machine-name> Command to log in to the virtual machine.

    2. modify /var/lib/boot2docker/profile Files, changing --registry-mirror=<your accelerate address> Add to EXTRA_ARGS Medium.

    3. implement sudo /etc/init.d/docker restart Command to restart the Docker service.

Configure Containerd runtime image accelerator

Containerd specifies a configuration folder at startup, so that all subsequent configurations related to the image warehouse can be hot loaded in it without restarting Containerd.

  1. If /etc/containerd/config.toml The configuration file already contains config_path Configuration (e.g "/etc/containerd/cert.d" ), this step is unnecessary; If it does not exist, you can add the following in the configuration file config_path Restart Containerd to make the changes take effect.

     config_path = "/etc/containerd/certs.d"
    explain

    /etc/containerd/config.toml The non default path can be adjusted according to the actual use.

    1. If already plugins."io.containerd.grpc.v1.cri".registry , add a line below. Note that Indent is required. If not, it can be written anywhere.

       [plugins."io.containerd.grpc.v1.cri".registry] config_path = "/etc/containerd/certs.d"
    2. After that, you need to check whether there are original mirror related configurations in the configuration file, as follows:

       [plugins."io.containerd.grpc.v1.cri".registry.mirrors] [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] endpoint = [" https://registry-1.docker.io "]

      If there is an existing mirror related configuration, it needs to be cleaned.

    3. implement systemctl restart containerd Restart Containerd.

    4. If the startup fails, execute journalctl -u containerd The reason why the check failed is that the configuration file still has conflicts. You can make adjustments based on the error report.

  2. Specified in step 1 config_path Create in path docker.io/hosts.toml File.

    Write the following configuration in the file.

     server = " https://registry-1.docker.io " [host. "$(image accelerator address, such as https://xxx.mirror.aliyuncs.com )"] capabilities = ["pull", "resolve", "push"]
  3. Pull the Docker image to verify whether the acceleration is effective. If not, see Reference