You can create a custom image from an existing Elastic Compute Service (ECS) instance to serve as a template. This allows you to quickly launch new instances that have the same pre-configured software and settings, which is ideal for batch deployments and maintaining a standard environment.
How it works
When you create a custom image, the system creates a snapshot for each cloud disk (including the system disk and any data disks) attached to the source instance. This collection of snapshots forms the custom image. When you later use this image to create new instances, the system restores the cloud disk data from these snapshots to replicate the source instance's environment.
Instance type limitations
You cannot create a custom image from a local SSD (i series) instance type.
Procedure
Step 1: Prepare the instance
Before creating an image, you must clean and inspect the target instance to ensure the resulting image is secure, stable, and reusable.
Clean sensitive data: Log on to the instance and remove any sensitive data, such as personal files, passwords, private keys, or access credentials from configuration files. This prevents security risks that could arise from including sensitive information in the image.
Reserve system disk space: Ensure the system disk is not full. The image creation process requires sufficient free space.
(Conditional) Check system configurations: For Linux instances, do not upgrade the kernel or operating system version, as this may cause the image creation to fail or prevent instances launched from the image from starting. Additionally, check the following configuration items that affect image creation and use:
System logon and partition settings: Avoid modifying the default login username (root) or altering the system disk partitions. The system disk currently supports only a single root partition.
Sensitive system file configurations: Check the
/etc/fstab
file to ensure that the mounted data disk information in the file matches the data disks currently attached to the instance.Critical system directories: Confirm that critical system directories such as
/sbin
,/bin
, and/lib
have not been modified, as this could lead to system instability.
(Optional) Stop the instance: Running instances may have cached data that has not yet been written to a cloud disk. To ensure data consistency between the image and the instance, we recommend stopping the instance before creating the custom image.
Step 2: Create the custom image
Console
Go to the ECS console - Instances page. In the upper-left corner of the page, select the resource group and region where your target instance is located.
Click the ID of the target instance to open its details page. In the upper-right corner, click .
As prompted, configure the image Name and other optional parameters, then click OK.
ImportantDuring image creation, do not stop, start, or restart the instance. These actions can cause the creation process to fail.
The Check After Creation option is selected by default. This feature automatically runs an Image Check after creation to verify that the custom image is valid and can be used to launch functional ECS instances.
If you enable image family for your custom image, you can set its status to deprecated or available to manage seamless updates and rollbacks.
Go to the ECS console - Images page. On the Custom images tab, find the new custom image by its name. The image is ready to use when its Status changes to Available.
The time required to create an image depends on the size of the instance's cloud disks, as a snapshot must be completed for each disk before the image is usable.
API
Call the CreateImage API operation to create a custom image by specifying the InstanceId
. When the call succeeds, the system creates a new snapshot for each cloud disk of the specified instance.
What to do next
If you selected Check After Creation when creating the image, you can view the details in the Check Result column of the Custom Images list. If the report indicates any issues, you can use the public template ACS-ECS-RepairImage in CloudOps Orchestration Service (OOS) for a one-click repair, or fix them manually based on the recommendations in the report.
Use the custom image for other operations:
Create an instance from a custom or shared image. The billing method for a custom image is independent of the source ECS instance. For example, you can use a custom image from a subscription instance to create pay-as-you-go instances.
Billing
When you create a custom image, the system also creates snapshots for all cloud disks of the instance. Storage charges apply based on snapshot capacity and the snapshot billing rules.
The System Disk Snapshot Size displayed in the image list is for reference only. Your billing statement shows the actual billable capacity.
The cost of a custom image (that is, the storage fee for its associated snapshots) is independent of the source instance's billing method. Charges will continue to accrue as long as you do not delete the custom image and its associated snapshots, even if you release the source instance.
FAQ
Why do I get a permission denied error when creating a custom image as a RAM user?
Creating a custom image from an instance requires the ecs:CreateImage
permission, along with permissions to create snapshots and query instance resources. If the RAM policy attached to the account enforces tag requirements, you must add a tag during image creation, or the operation will fail due to insufficient permissions.
Why can't I delete a snapshot associated with a custom image?
To ensure the integrity and availability of a custom image, the system prevents you from directly deleting a snapshot referenced by an image. To delete the snapshot, you must first delete the corresponding custom image.
How can I create a custom image from cloud disks attached to different instances?
Use the create a custom image from snapshots method. This lets you use a system disk snapshot and data disk snapshots from different instances to create a single custom image.