Creates an image component. Image components are used to store the builder template commands that are commonly used when you create images.

Description

When you call this operation, take note of the following items:

  • Only custom image components can be created.
  • Image components can be used to create only Linux images, so you must set the SystemType parameter to Linux.
  • You must configure the image component type to image building component by setting the ComponentType parameter to Build.
  • You can use Dockerfile to edit the content of image components and then pass the edited content into the Content parameter. The content cannot be greater than 16 KB in size and can contain up to 127 commands. FROM commands cannot be used in image components. For information about the commands that are supported, see Commands supported by Image Builder.

You can use image components to create image templates in the Elastic Compute Service (ECS) console, but cannot call API operations to use image components to create image templates. For more information, see Overview.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateImageComponent

The operation that you want to perform. Set the value to CreateImageComponent.

RegionId String Yes cn-hangzhou

The ID of the region in which to create the image component. 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 component.

Name String No testComponent

The name of the image component. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with http:// or https://. It can contain letters, digits, colons (:), underscores (_), periods (.), and hyphens (-).

Note If you do not specify the Name parameter, the return value of ImageComponentId is used by default.
Description String No This is description.

The description of the image component. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

SystemType String No Linux

The operating system type supported by the image component. Only Linux is supported. Set the value to Linux.

Default value: Linux.

ComponentType String No Build

The type of the image component. Only image building components are supported. Set the value to Build.

Default value: Build.

Content String No RUN yum update -y

The content of the image component. The content can consist of up to 127 commands.

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 value, but you must make sure that it is unique among different requests. The ClientToken value can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

Tag.N.Key String No TestKey

The key of tag N. Valid values of N: 1 to 20. The tag key cannot be an empty string. It can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

Tag.N.Value String No TestValue

The value of tag N. Valid values of N: 1 to 20. The tag value can be an empty string. It can be up to 128 characters in length and cannot start with acs: or contain http:// or https://.

Response parameters

Parameter Type Example Description
ImageComponentId String ic-bp67acfmxazb4p****

The ID of the image component.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=CreateImageComponent
&RegionId=cn-hangzhou
&Name=testComponent
&Description=This is description.
&SystemType=Linux
&ComponentType=Build
&Content=RUN yum update -y
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateImageComponentResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
    <ImageComponentId>ic-bp67acfmxazb4p****</ImageComponentId>
</CreateImageComponentResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "ImageComponentId" : "ic-bp67acfmxazb4p****"
}

Error codes

HTTP status code Error code Error message Description
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The error message returned because the specified ResourceGroupId parameter does not exist.

For a list of error codes, visit the API Error Center.