You can use the P2P acceleration feature on hosts where Docker is installed to accelerate image pulling and reduce the time used to deploy applications. This topic describes how to use the P2P acceleration feature on hosts where Docker is installed.

Prerequisites

Procedure

  1. View the ID of the Container Registry Enterprise Edition instance.
    1. Log on to the Container Registry console.
    2. In the top navigation bar, select a region.
    3. In the left-side navigation pane, click Instances.
    4. On the Instances page, click the Container Registry Enterprise Edition instance whose ID you want to view.
      On the Overview page, view the ID of the Container Registry Enterprise Edition instance in the Instance section.
  2. Log on to an Elastic Compute Service (ECS) instance. For more information, see Connect to a Linux instance by using an SSH key pair.
  3. Run the following command to download the installation package of the P2P component:
    docker run --rm -v /var/lib/aliyun-acr/p2p:/var/lib/aliyun-acr/p2p registry.cn-hangzhou.aliyuncs.com/acr-toolkit/p2p-installer-manual:v1.0.6-b6b9f5f9-aliyun
  4. Configure the P2P component.
    /var/lib/aliyun-acr/p2p/scripts/01-init.sh --ak <aliyun-ak> --sk <aliyun-sk> --port 65001 --instance <acr-ee-instance-id>
    Replace the AccessKey ID, AccessKey secret, ID of the Container Registry Enterprise Edition instance, and the port used by the P2P component in the preceding command as required. By default, the P2P component uses port 65001 on nodes.
    Note The AccessKey ID and AccessKey secret are used only to obtain information about the Container Registry Enterprise Edition instance during configuration initialization.
    After the P2P component is configured, the /var/lib/aliyun-acr/p2p directory is generated.
  5. Run the following command to start the P2P component.
    Note To install the P2P component on other ECS instances, copy the directory that was generated in Step 4 to these ECS instances. Then, run the command to start the P2P component on these ECS instances.
    /var/lib/aliyun-acr/p2p/scripts/02-run.sh
  6. Run the following command to log on to an image repository by using the P2P-accelerated domain name:
    docker login <P2P-accelerated domain name of the Container Registry Enterprise Edition instance>
    The P2P-accelerated domain name is in the following format: <Name of the Container Registry Enterprise Edition instance>>-registry-vpc.distributed.<Region where the Container Registry Enterprise Edition instance resides>.cr.aliyuncs.com:<Port used by the P2P component>.
  7. Run the following command to pull an image by using the P2P-accelerated domain name:
    docker pull <P2P-accelerated domain name of the Container Registry Enterprise Edition instance>/test/busybox:latest
  8. Optional:Run the following command to uninstall the P2P component:
    /var/lib/aliyun-acr/p2p/scripts/03-uninstall.sh