All Products
Search
Document Center

:CreateImageComponent

更新時間:Nov 30, 2023

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

Usage notes

Take note of the following items:

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

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.

Tag.N.Key String No TestKey

The key of tag N to add to the image component. 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 http:// or https://. The tag key cannot start with acs: or aliyun.

Tag.N.Value String No TestValue

The value of tag N to add to the image component. 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 http:// or https://. The tag value cannot start with acs:.

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

Note If the Name parameter is not set, the return value of ImageComponentId is used as the image component name 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 type of the operating system 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 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 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

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

400 EmptyCommandContent.RUN %s. If the RUN command exists in the template, you must specify RUN.
400 EmptyCommandContent.ENV %s. If the ENV command exists in the template, you must specify ENV.
400 EmptyCommandContent.LABEL %s. If the LABEL command exists in the template, you must specify LABEL.
400 EmptyCommandContent.COPY %s. If the COPY command exists in the template, you must specify COPY.
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 NotEmptyCommandContent.RESTART %s. If the RESTART command exists in the template, you must leave RESTART empty.
400 EmptyCommandContent.WORKDIR %s. If the WORKDIR command exists in the template, you must specify WORKDIR.
400 EmptyCommandContent.USER %s. If the USER command exists in the template, you must specify USER.
400 QuotaExceed.ImageComponent %s. The quotas of the image components in the current region are exhausted.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The resource group is not found.

For a list of error codes, see Service error codes.