You can customize image content based on image templates and build images in different regions and accounts. This topic describes how to create an image template in the ECS console.

Background information

  • Before you start the procedure, 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 the custom image templates to be created.
    • When you use an image template to build an image, you must create an intermediate instance to help build the image. The intermediate instance is billed on a pay-as-you-go basis. For more information, see Pay-as-you-go.
    • Each command used to build an image template cannot exceed 16 KB in size. A maximum of 127 commands can be configured.
  • Commands supported by Image Builder
  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Deployment & Elasticity > Auto Provisioning.
  3. In the top navigation bar, select a region.
  4. On the Image Builder Management page, click Create Image Template.
    If you access Image Builder for the first time, the Image Builder welcome page appears. Click Create Image Template.
  5. Configure parameters to create an image template. Then, click Create.
    The following tables describe the parameters.
    • Parameters in the Basic Information section
      Parameter Description
      Template Name The name of the image template. This parameter is required.
      Description The description of the image template.
      Tag The tags of the image template, which are used to manage resources. For more information, see Overview.
    • Parameters in the Configure Source Image section
      Parameter Description
      Import Template through Dockerfile You can import the edited template content by using Dockerfile. The imported content overwrites the Source Image Type, Image, and Image Template settings that you configured in the ECS console. Exercise caution when you perform this operation.
      Source Image Type The source image type of the image template. Valid values: Images and Image Family.
      Image or Image Family This parameter is 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 Image, Public Image, or Shared Image from the first Image drop-down list. You can select an image ID or image version from the second Image drop-down list.
      • If you set Source Image Type to Image Family, you must select an image family from the Image Family drop-down list.
      Image Template You must configure Command and Content for the image template. For information about supported commands, see the Background Information section. After you configure the parameters, you can click Preview to view the template content.
      Note You can select Existing Component for Command and the ID of an existing component for Content.
    • Parameters in the Configure Intermediate Instance section
      Parameter Description
      vSwitch Select a vSwitch that is available in the current region. If you do not configure this parameter, the system creates a temporary VPC and vSwitch. Make sure that the unused quota is sufficient in the region.
      Instance Type Configure the instance type of 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 resource availability of instance types. For example, the ecs.g6.large instance type is selected by default. If available ecs.g6.large resources are insufficient, the ecs.g6.xlarge instance type is selected.
      System Disk Size Configure the system disk size of the intermediate instance. Unit: GiB. Valid values: 20 to 500. Default value: 40.
      Public Bandwidth (Mbit/s) Configure the public bandwidth of the intermediate instance. Default value: 0. This value indicates that you cannot access the image template over the Internet. If your image building contains a command such as a download command that requires to access 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 choose whether to retain the intermediate instance.
      Note If you choose to retain the intermediate instance, the instance continues to be billed. When you no longer need the intermediate instance, manually release it at your earliest opportunity. For more information, see Release an instance.
    • Parameters in the Configure Image Distribution section
      Parameter Description
      Destination Image Name Configure the name prefix of the built image. The system generates the final complete image name that consists of the prefix and the ID of the building task (ExecutionId) in the format of <The custom name prefix>_<The ID of the building task>.
      Current Region The current region of the ECS console is displayed.
      Default Distribution Region If you want to copy the built image to multiple regions, you can set the distribution regions. Then, the built image is distributed to the specified regions. This parameter can be empty. You can specify up to 20 distribution regions.
      Shared User ID If you want to share the built image to other Alibaba Cloud accounts, you can configure the user IDs (UIDs) to which to share the image. Then, the built image is shared to the specified Alibaba Cloud accounts in the same region as the built image. This parameter can be empty. You can specify up to 20 UIDs.
      Note You can click the profile picture in the upper-right corner of the console, and choose Account Management > Security Settings to view the Account ID.
      Execute Immediately You can choose whether to execute the image building task immediately. If you choose not to execute image building task immediately, you can manually execute the task later. For more information, see Execute an image building task.
    After the image template is created, you can view the image template on the Image Builder Management page.