This topic describes how to call the CopyImage operation by using Alibaba Cloud command-line interface (CLI) to copy a custom image from one region to another.

Background information

You can call the CopyImage operation to copy a custom image from one region to another. This operation helps you deploy and copy ECS instances across regions. For more information, see CreateImage.

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.
    In this example, query the ID of an image by using its name.
    aliyun ecs DescribeImages --RegionId cn-hangzhou --ImageName demoName --output cols=Images.Image[].ImageId
    Sample response:
  2. Copy the image to a different region.
    In this example, copy image m-bp1503ydxxrppctb**** from China (Hangzhou) to China (Shanghai).
    aliyun ecs CopyImage --RegionId cn-hangzhou --ImageId m-bp1503ydxxrppctb**** --DestinationImageName copydemoimage --DestinationDescription copydemoimage --DestinationRegionId  cn-shanghai


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