An image component stores one or more commands, such as application, configuration, and test commands, that are used to build an image. You can add image components to an image template to customize image content. The system provides default system components that you can use. However, if you have specific application scenarios or requirements, you may need custom components or specific software versions. In these cases, you can create new components to meet your business needs. This topic describes how to create an image component in the ECS console.
Image templates created using system components are stable and reliable. We recommend that you use system components to create your image templates.
Prerequisites
When you create an image component or image template for the first time, the system automatically creates a service-linked role named AliyunServiceRoleForECSImageBuilder. This role grants Image Builder access to related cloud resources. If you use a Resource Access Management (RAM) user, you must grant permissions to the RAM user to manage the service-linked role for Image Builder. An Alibaba Cloud account has this permission by default. For more information, see Manage the service-linked role for Image Builder.
Limits
Note the following limits:
You can create and modify custom components. You cannot create or modify system components.
The content size of each command cannot exceed 16 KB. An image component can contain a maximum of 127 commands. For more information about supported commands, see Image Builder commands.
Procedure
Go to ECS console - Image Builder.
In the top navigation bar, select the region and resource group of the resource that you want to manage.
On the Image Builder page, click the Image Components tab.
NoteWhen you first access Image Builder, click Experience Now.
On the Custom Components tab, click Create Image Component.
Configure the parameters for the image component, and then click OK.
The following table describes the configuration items for an image component.
Parameter
Description
Name
Set a name for the image component.
Component Type
Build and Test components are supported.
A Build component is used to customize your image content and can be used only in build templates.
A Test component is used to test whether your built image meets expectations and can be used only in test templates.
System Type
Set the operating system for the image component. Valid values are Linux and Windows.
Release Type
The version number of the component. It is used together with the component name.
Configure Component Content
Instructions in YAML format (for Linux and Windows) and Dockerfile format (for Linux only) are supported.
YAML format
Directly enter the instruction content in YAML format.
Alternatively, select a predefined system template from the sample templates to install applications such as PHP, MySQL, or Nginx. When you use an image built with this component, the latest stable versions of these applications are installed on the created ECS instances. If a version does not meet your requirements, specify the version you need. For example, change the command
sudo yum -y install nginxtosudo yum -y install nginx-<version>.

Dockerfile format
On the Visualization tab, click Add Command to set component instructions. Alternatively, on the Script tab, directly enter the instruction content.

For more information about instructions in YAML and Dockerfile formats, see Image Builder commands.
Advanced Configuration
As needed, set the description and tags for the component.
References
You can also call the CreateImageComponent API operation to create an image component and the DescribeImageComponents API operation to view information about image components.
After you create an image component, you can use it to create an image template. For more information, see Create an image template and execute a build task.
If you no longer need an image component, you can delete it. For more information, see Delete an image component.