All Products
Search
Document Center

Elastic Compute Service:Create an image template and run an image building task

Last Updated:Feb 21, 2024

If you use an image template to customize image content, you can configure cross-region and cross-account image distribution. After the image template is created, the system generates a building task based on the content configured in the image template. During the task execution, the system automatically checks the parameters in the image template. This topic describes how to create an image template in the Elastic Compute Service (ECS) console and how to use the image template to run an image building task.

Create an image template

Considerations

Before you create an image template, take note of the following items:

  • Only custom image templates can be created.

  • You can configure only public, custom, or shared Linux images, or image families as the source images of custom image templates.

  • When you use an image template to create an image, you must create an intermediate instance. You are charged for the intermediate instance on a pay-as-you-go basis. For more information, see Pay-as-you-go.

Procedure

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Deployment & Elasticity > icon1 > Image Builder.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Image Builder page, click Create Image Template.

    The first time you access Image Builder, the Image Builder welcome page appears. You must click Experience Now to go to the Image Builder page.

  5. Configure the parameters and click OK.

    The following tables describe the parameters.

    • Parameters in the Basic Information section

      Parameter

      Description

      Template Name

      Required. Specify a name for the image template.

      Description

      Specify a description for the template.

      Tag

      Add tags to the image template. For information about tags, see Overview.

    • Parameters in the Configure Source Image section

      Parameter

      Description

      Import Template through Dockerfile

      Specific template building commands are compatible with specific Dockerfile commands. You can import the edited template content by using Dockerfile.

      Important

      The imported template content overwrites the Source Image Type, Image, and Image Content parameters that you configured in the ECS console. Proceed with caution.

      Source Image Type

      The source image type of the image template. Valid values: Images and Image Family.

      Images or Image Family

      Required. This parameter varies based on the settings of Source Image Type.

      Note

      Only Linux images are supported.

      • If you set Source Image Type to Images, you can select Custom Images, Public Images, or Shared Images from the first Image drop-down list. You can select an image ID or image version from the second Image drop-down list.

      • If Source Image Type is set to Image Family, select an existing image family or enter the name of an image family.

      Template Content

      Click Add Command and configure the commands and content. Then, click Preview to view the template content.

      Note
      • Each command cannot exceed 16 KB in size. A maximum of 127 commands can be configured.

      • You can select Custom Component or System Component. The value of this parameter is the ID of the component. Image templates that are created by using system components provide stable and reliable images. We recommend that you use system components to create image templates.

      • For information about supported commands, see Commands supported by Image Builder.

    • Parameters in the Configure Intermediate Instance section

      Parameter

      Description

      vSwitch

      Select a vSwitch that is available in the current region. If you do not set a value, the system creates a temporary virtual private cloud (VPC) and vSwitch. Make sure that the resource quotas in your region are sufficient.

      Instance Type

      Select an instance type for the intermediate instance. If you do not configure this parameter, an instance type that provides the fewest vCPUs and memory resources is automatically selected. This configuration is subject to the resource availability of instance types. For example, the ecs.g6.large instance type is automatically selected. If available ecs.g6.large resources are insufficient, the ecs.g6.xlarge instance type is selected.

      System Disk Size

      Specify the system disk size for the intermediate instance. Valid values: 20 GiB to 500 GiB. Default value: 40 GiB.

      Public Bandwidth (Mbps)

      Specify the public bandwidth for the intermediate instance. Default value: 0. This value indicates that the image template does not have Internet connectivity. If your image template content contains a command that requires access to the Internet, you must set a non-zero value for the public bandwidth. Otherwise, the image building task fails.

      Release if Image Building Fails

      You can select whether to retain the intermediate instance.

      Note

      If you select No to retain the intermediate instance, you continue to be charged for the instance after the image building task fails. When the intermediate instance is no longer needed, you must manually release it at the earliest opportunity. For more information, see Release an instance.

    • Parameters in the Configure Image Distribution section

      Parameter

      Description

      Destination Image Name

      Specify a name prefix for the image that you want to create. The system appends the ID of the image building task (ExecutionId) to the prefix to generate a full name of the image in the <Custom name prefix>_<ID of the image building task> format.

      Current Region

      The current region of the ECS console is displayed.

      Destination Region

      If you want to copy an image to multiple regions, you can specify the destination regions. The image is distributed to the specified destination regions. You can specify up to 20 destination regions or no destination region.

      Shared User ID

      If you want to share the created image with other Alibaba Cloud accounts, you can specify the UIDs of the Alibaba Cloud accounts. The created image is shared with the specified Alibaba Cloud accounts in the same region. You can specify up to 20 UIDs or no UID.

      Execute Immediately

      You can select whether to immediately execute an image building task. If you select No to not immediately execute an image building task, you can manually execute a task. For more information, see the Execute an image building task section in this topic.

    After you create the image template, you can view it on the Image Builder page.

Run an image building task

If you select No to not immediately run an image building task when you create an image template, you must manually run an image building task to build an image.

Considerations

Before you run an image building task based on an image template, take note of the following items:

  • Only one image building task can be run at a time based on an image template.

  • You can cancel an image building task multiple times. Canceling an image building task does not interfere with the execution of other ongoing image building tasks.

Procedure

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Deployment & Elasticity > icon1 > Image Builder.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Image Templates tab of the Image Builder page, find the image template based on which you want to run an image building task and click Run in the Actions column.

    Note

    You can cancel ongoing image building tasks. To cancel an ongoing image building task that is based on an image template, click the image template ID, find the image building task on the Building History tab, and then click Cancel in the Actions column.

    • After the image building task is completed, Success is displayed in the Status column and the ID of the image that is built based on the image template is displayed in the Image ID column. You can click the image ID to view the details of the image in the ECS console.

    • If the image building task is in the Failed state, you can view the detailed error message in the Execution Result column to identify and troubleshoot the issue.

References

After you create an image by using an image template, you can perform the following operations: