You can call this operation to create an image component. Image components are used to store template build commands that are commonly used when you build images.

Description

When you create an image component, take note of the following items:

  • This operation can only be used to create custom image components.
  • The images must run Linux operating systems, so you must set the SystemType parameter to Linux.
  • You must configure the image component type to image build component by setting the ComponentType parameter to Build.
  • You can use Dockerfile to edit content of image components, and then pass the edited content into the Content parameter. The content size must not be greater than 16 KB. FROM commands cannot be used in image components. An image component supports up to 127 commands. For information about commands supported by Image Builder, see Description of commands supported by Image Builder.
Note 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.

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 region ID of the image component. You can call the DescribeRegions operation to query the most recent region list.

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. It cannot start with acs: or contain http:// or https://.

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 and can contain letters, digits, colons (:), underscores (_), periods (.), and hyphens (-). It must start with a letter and cannot start with http:// or https://.

Note If you do not specify the Name parameter, the return value of ImageComponentId is used.
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 build 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 consists of up to 127 commands. For information about commands supported by Image Builder and the formats of the commands, see Description of commands supported by Image Builder.

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 only contain ASCII characters and cannot exceed 64 characters in length. For more information, see How can I ensure idempotence?

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

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

JSON format

{
    "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 resource group does not exist.

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