This topic describes how to call the CopyImage operation by using Alibaba Cloud CLI to copy a custom image from one region to another.

Background information

By copying images, you can deploy and copy ECS instances across regions. We recommend that you read the description of the operation before you call the operation. For more information, see CopyImage.

When you call an API operation through Alibaba Cloud CLI, make sure that request parameter values of different data types are in required formats. For more information, see Parameter format overview.

Request examples

  1. Call the DescribeImages operation to query the ID of the image that you want to copy. For more information, see DescribeImages.
    In this example, the image name is used to query the ID of the image.
    aliyun ecs DescribeImages --RegionId cn-hangzhou --ImageName demoName --output cols=Images.Image[].ImageId
    Sample response:
    Images.Image[].ImageId
    ----------------------
    [m-bp1503ydxxrppctb****]
  2. Copy the image to a different region.
    In this example, the m-bp1503ydxxrppctb**** image in the China (Hangzhou) region is copied to the China (Shanghai) region.
    aliyun ecs CopyImage --RegionId cn-hangzhou --ImageId m-bp1503ydxxrppctb**** --DestinationImageName copydemoimage --DestinationDescription copydemoimage --DestinationRegionId  cn-shanghai

Result

{
        "ImageId": "m-uf6avoqpklopyd0z****",
        "RequestId": "B719BE06-0C92-4E3F-9A1D-064DB3C50F5B"
}