An image cache accelerates image pulls and reduces startup time for Elastic Container Instance (ECI) instances. This topic describes how to create, query, update, and delete image caches.
Create an image cache
You can manually create an image cache in the console or by calling an API operation.
ECI can create image caches automatically. When you create an ECI instance with automatic image cache matching enabled, the system creates a new image cache if no existing one is matched.
Before you begin
-
Creating an image cache incurs charges. We recommend that you review the billing details before proceeding. For more information, see Image cache billing.
-
Before you create an image cache, you must estimate the total size of the container images to be cached. If the total image size exceeds the specified cache size, the creation fails.
-
When creating an image cache, the system automatically creates an intermediate ECI instance and a cloud disk. Do not delete these resources during this process; otherwise, the image cache creation will fail.
-
When you create an image cache, a corresponding snapshot is generated. Do not delete the snapshot. Otherwise, the image cache becomes invalid.
Create an image cache by API
You can call the CreateImageCache API operation to create an image cache. The following table describes the key request parameters. For more information, see CreateImageCache.
|
Parameter |
Type |
Example |
Description |
|
RegionId |
string |
cn-hangzhou |
The region ID. |
|
SecurityGroupId |
string |
sg-uf66jeqopgqa9hdn**** |
The security group ID. |
|
VSwitchId |
string |
vsw-uf6h3rbwbm90urjwa**** |
The vSwitch ID. |
|
ImageCacheName |
string |
testcache |
The name of the image cache. |
|
Image.N |
array |
registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.15.10-perl |
The container images used to create the image cache. |
|
ImageCacheSize |
integer |
20 |
The size of the image cache in GiB. The default value is 20. |
|
RetentionDays |
integer |
7 |
The retention period of the image cache, in days. The image cache is deleted after this period expires. |
|
AutoMatchImageCache |
boolean |
false |
Specifies whether to enable image layer reuse. If you enable this feature, a new image cache can reuse layers from an existing image cache. This speeds up the creation process. The default value is false. |
|
Flash |
boolean |
true |
Specifies whether to enable the instant image cache feature. This feature accelerates image cache creation. The default value is false. |
When you create an image cache, you can configure the AcrRegistryInfo parameters to pull images from a Container Registry Enterprise Edition instance without credentials. For more information, see Configure password-free access to a Container Registry Enterprise Edition instance.
Create an image cache in the console
-
On the Image Cache page in the Elastic Container Instance console, click Create Image Cache.
-
On the page that appears, configure the parameters.
-
Basic parameters: Specify the region, availability zone, Virtual Private Cloud (VPC), and security group for the intermediate instance.
ImportantIf container images are pulled over the internet and the selected Virtual Private Cloud (VPC) does not have a NAT gateway, you must assign an elastic IP address (EIP).
-
Image Cache: Enter a name, select an image address and version, and specify the size and retention period for the image cache.
-
Image Repository Credentials: For a private image, enter the address, username, and password of the image repository.
-
-
Select the Terms of Service checkbox, click Confirm Creation, and follow the prompts to complete the process.
-
On the Image Cache page, check the creation status.
The Status column displays the creation progress. The image cache is successfully created when the status changes to Ready. You can click the image cache ID to view its details and events.
Query image caches
After creating an image cache, you can query its details. An image cache can be used only when it is in the Ready state.
You can query an image cache in one of the following ways:
-
Call the DescribeImageCaches API operation to query image caches. For more information, see DescribeImageCaches.
-
On the Image Cache page of the Elastic Container Instance console, view the name and status of an image cache. You can also click the image cache ID to view its details and events.
Update an image cache
If an image cache is in the Ready or UpdateFailed state, you can call the UpdateImageCache API operation to update it. You can update properties such as the container image, retention period, and image repository information. For more information, see UpdateImageCache.
Delete an image cache
Each image cache is associated with a snapshot, which incurs storage fees. If you no longer need an image cache that was created without a retention period, we recommend deleting it promptly to avoid unnecessary charges.
Image caches that are automatically created are managed by Alibaba Cloud and are automatically deleted after a specific period.
-
An automatically created image cache that is never used is deleted after 7 days.
-
An automatically created image cache is deleted if it has not been used for 30 days.
You can delete an image cache in one of the following ways:
-
Call the DeleteImageCache API operation to delete an image cache. For more information, see DeleteImageCache.
-
On the Image Cache page of the Elastic Container Instance console, select the image cache that you want to delete and click Delete Image Cache at the bottom of the page.