Creates an image template. Image templates can be used to create images.
Usage notes
You can use image templates to specify custom image content and create images across regions and accounts. Take note of the following items:
- You can create only custom image templates.
- You can configure only public, custom, or shared Linux images or image families as the source images of the custom image templates to be created.
- When you use an image template to create an image, you must create an intermediate Elastic Compute Service (ECS) instance to help create the image. The intermediate instance is billed by using the pay-as-you-go billing method. For more information, see Pay-as-you-go.
When you use the BuildContent
parameter to specify the content of image templates, take note of the following items:
- If the
BuildContent
value containsFROM
commands, theFROM
commands override the values ofBaseImageType
that specifies the type of the source images andBaseImage
that specifies the source image. - If the
BuildContent
value does not containFROM
commands, the system creates aFROM
command that consists of theBaseImageType
andBaseImage
values in the format of<BaseImageType>:<BaseImage>
and adds the command to the first line of the template content. - You can use Dockerfile to edit the content of image templates and then pass the edited content into the
BuildContent
parameter. The content cannot be greater than 16 KB in size. The content can contain up to 127 commands. For information about commands supported by image templates, see Description of commands supported by Image Builder.
You can use image components to create image templates in the ECS console, but cannot call API operations to use image components to create image templates. For more information, see Overview of Image Builder.
Debugging
Request parameters
Parameter |
Type |
Required |
Example |
Description |
Tag.N.Key | String | No | TestKey | The key of tag N to add to the image template. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain |
Tag.N.Value | String | No | TestValue | The value of tag N to add to the image template. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain |
Action | String | Yes | CreateImagePipeline | The operation that you want to perform. Set the value to CreateImagePipeline. |
RegionId | String | Yes | cn-hangzhou | The ID of the region in which to create the image template. You can call the DescribeRegions operation to query the most recent region list. |
ResourceGroupId | String | No | rg-bp67acfmxazb4p**** | The ID of the resource group to which to assign the image template. |
AddAccount.N | Long | No | 1234567890 | The ID of Alibaba Cloud account N to which to share the image that will be created based on the image template. Valid values of N: 1 to 20. |
ToRegionId.N | String | No | cn-hangzhou | The IDs of regions to which to distribute the image that will be created based on the image template. Valid values of N: 1 to 20. If you do not specify this parameter, the image is created only in the current region. |
BaseImageType | String | Yes | IMAGE | The type of the source image. Valid values:
|
BaseImage | String | Yes | m-bp67acfmxazb4p**** | The source image.
|
Name | String | No | testImagePipeline | The template name. The name must be 2 to 128 characters in length. The name must start with a letter and cannot start with Note If the Name parameter is not set, the return value of ImagePipelineId is used by default. |
Description | String | No | This is description. | The description of the image template. The description must be 2 to 256 characters in length and cannot start with |
ImageName | String | No | testImageName | The name prefix of the image to be created. The name prefix must be 2 to 64 characters in length. It must start with a letter and cannot start with The system generates the final complete image name that consists of the specified prefix and the ID of the build task ( |
VSwitchId | String | No | vsw-bp67acfmxazb4p**** | The ID of the vSwitch. If you do not specify this parameter, a new VPC and vSwitch are created. Make sure that the VPC quota in your account is sufficient. For more information, see Limits and quotas. |
InstanceType | String | No | ecs.g6.large | The instance type. You can call the DescribeInstanceTypes operation to query instance types. If you do not specify this parameter, an instance type that provides the fewest vCPUs and memory resources is automatically selected. This configuration is subject to the resource availability of instance types. For example, the ecs.g6.large instance type is selected. If the available ecs.g6.large resources are insufficient, the ecs.g6.xlarge instance type is selected. |
SystemDiskSize | Integer | No | 40 | The system disk size of the intermediate instance. Unit: GiB. Valid values: 20 to 500. Default value: 40. |
InternetMaxBandwidthOut | Integer | No | 0 | The size of the outbound public bandwidth for the intermediate instance. Unit: Mbit/s. Valid values: 0 to 100. Default value: 0. |
DeleteInstanceOnFailure | Boolean | No | true | Specifies whether to release the intermediate instance if the image fails to be created. Valid values:
Default value: true. Note If the intermediate instance fails to be started, the instance is released by default. |
BuildContent | String | No | FROM IMAGE:m-bp67acfmxazb4p**** | The content of the image template. The content cannot be greater than 16 KB in size. The content can contain up to 127 commands. For more information about the commands that are supported, see the "Usage notes" section of this topic. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-426655440000 | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. |
Response parameters
Parameter |
Type |
Example |
Description |
ImagePipelineId | String | ip-2ze5tsl5bp6nf2b3**** | The ID of the image template. |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E | The ID of the request. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=CreateImagePipeline
&BaseImage=m-bp67acfmxazb4p****
&BaseImageType=IMAGE
&RegionId=cn-hangzhou
&Name=testImagePipeline
&BuildContent=FROM IMAGE:m-bp67acfmxazb4p****
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateImagePipelineResponse>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
<ImagePipelineId>ip-2ze5tsl5bp6nf2b3****</ImagePipelineId>
</CreateImagePipelineResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
"ImagePipelineId" : "ip-2ze5tsl5bp6nf2b3****"
}
Error codes
HTTP status code |
Error code |
Error message |
Description |
400 | QuotaExceed.ImagePipeline | %s. | The image template quota of your account in this region is exhausted. |
400 | NoPermission | %s. | You do not have the permissions to perform this operation. Apply for the permissions required to perform the operation. |
400 | EmptyCommandContent.LABEL | %s. | If the LABEL command exists in the template, you must specify LABEL. |
400 | EmptyCommandContent.ENV | %s. | If the ENV command exists in the template, you must specify ENV. |
400 | EmptyCommandContent.ENTRYPOINT | %s. | If the ENTRYPOINT command exists in the template, you must specify ENTRYPOINT. |
400 | EmptyCommandContent.CMD | %s. | If the CMD command exists in the template, you must specify CMD. |
400 | EmptyCommandContent.COPY | %s. | If the COPY command exists in the template, you must specify COPY. |
400 | EmptyCommandContent.WORKDIR | %s. | If the WORKDIR command exists in the template, you must specify WORKDIR. |
400 | NotEmptyCommandContent.RESTART | %s. | If the RESTART command exists in the template, you must leave RESTART empty. |
400 | EmptyCommandContent.USER | %s. | If the USER command exists in the template, you must specify USER. |
400 | EmptyCommandContent.RUN | %s. | If the RUN command exists in the template, you must specify RUN. |
404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The resource group is not found. |
404 | ImageComponent.NotFound | %s. | The specified image component ID is not found. |
For a list of error codes, see Service error codes.