Create a custom image component with specific commands when system components do not meet your requirements.
Use system components whenever possible to ensure stability and reliability.
Prerequisites
If you use a RAM user, grant it permission to manage the service-linked role AliyunServiceRoleForECSImageBuilder. See Manage the service-linked role for Image Builder.
Limitations
Note the following limitations:
-
You can only create and modify custom components, not system components.
-
Each command cannot exceed 16 KB. A component supports up to 127 commands. See Image Builder commands.
Procedure
Go to ECS Console - Image Builder.
In the upper-left corner of the page, select a region and resource group.
-
On the Image Builder page, click Image Components.
NoteIf you access Image Builder for the first time, click Try Now.
-
On the Custom Components tab, click Create Component.
-
Configure the parameters and click OK.
The following table describes the parameters.
Parameter
Description
Name
The component name.
Component Type
Valid values: Build and Test.
-
Build: customizes image content. Used only in build templates.
-
Test: validates the built image. Used only in test templates.
System Type
Valid values: Linux and Windows.
Release Type
The component version number. The name and version together identify a specific component version.
Configure Component Content
The component instructions. YAML is supported for Linux and Windows. Dockerfile is supported for Linux only.
-
YAML format
-
Enter instructions directly in YAML format.
-
You can also select a predefined system template, such as PHP, MySQL, or Nginx. The system installs the latest stable version by default. To specify a version, modify the install command. For example, change
sudo yum -y install nginxtosudo yum -y install nginx-<version>.
Select Create Install Nginx Component from the template drop-down list. The YAML editor generates a configuration with three tasks: BuildNginx (install Nginx), RunNginx (run
sudo systemctl start nginxto start the service), and SetRunNginx (set Nginx to start on boot). -
-
Dockerfile format
On the Visual View tab, click Add Command to add instructions individually. On the Script View tab, enter content directly.
For example, select LABEL and enter
LABEL user="username"\ date="2020-11-11" key="value", or select RUN and enterRUN echo hello;\ echo world;.
See Image Builder commands for the full list of supported instructions and syntax.
Advanced Settings
(Optional) Add a description and tags.
-
References
-
Call CreateImageComponent to create a component, or DescribeImageComponents to query components.
-
After you create an image component, use it to create an image template and run a build task.
-
To remove an unused component, see Delete an image component.