Creates an image component. Image components are used to store the image template commands that are commonly used to create images.
Operation description
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 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 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 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
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ecs:CreateImageComponent | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The region ID. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
ResourceGroupId | string | No | The ID of the resource group. | rg-bp67acfmxazb4p**** |
Tag | array<object> | No | The tags. | |
object | No | |||
Key | string | No | The key of tag N. 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. | TestKey |
Value | string | No | The value of tag N. 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:. | TestValue |
Name | string | No | The component name. The name must be 2 to 128 characters in length. The name 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 you do not configure Name , the return value of ImageComponentId is used.
| testComponent |
Description | string | No | The description. The description must be 2 to 256 characters in length and cannot start with http:// or https://. | This is description. |
SystemType | string | No | The operating system type supported by the image component. Only Linux is supported. Set the value to Linux. Default value: Linux. | Linux |
ComponentType | string | No | The type of the image component. Only image build components are supported. Set the value to Build. Default value: Build. | Build |
Content | string | No | The content of the image component. The content consists of up to 127 commands. | RUN yum update -y |
ClientToken | string | No | The client token that is used to ensure the idempotency 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. | 123e4567-e89b-12d3-a456-426655440000 |
Response parameters
Examples
Sample success responses
JSON
format
{
"ImageComponentId": "ic-bp67acfmxazb4p****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidCommand.Component | Image component does not support component command. | - |
400 | InvalidName.Malformed | %s | - |
400 | InvalidDescription.Malformed | %s | - |
400 | InvalidSystemType.NotSupportedValue | %s | - |
400 | InvalidComponentType.NotSupportedValue | %s | - |
400 | InvalidContent.LengthExceeded | %s | - |
400 | InvalidImageTemplateCommandSize.ExceededMaxNumber | %s | - |
400 | InvalidImageTemplateCommand.NotSupported | %s | - |
400 | InvalidCommandContent.RUN | %s | - |
400 | InvalidCommandContent.ENV | %s | - |
400 | InvalidCommandContent.WORKDIR | %s | - |
400 | InvalidCommandContent.COPY | %s | - |
400 | InvalidCommandContent.USER | %s | - |
400 | InvalidCommandContent.CMD | %s | - |
400 | InvalidCommandContent.ENTRYPOINT | %s | - |
400 | MissingParameter.Content | %s | - |
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 specify RESTART. |
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. | Image component quota exceeded in current region. |
404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The specified resource group does not exist. |
404 | NotSupportedCommand.FROM | %s | - |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-08-08 | The Error code has changed | View Change Details |
2023-03-28 | The Error code has changed | View Change Details |