Using an image cache to create Elastic Container Instance (ECI) instances accelerates container image pulls and reduces instance startup time. This topic covers the features of image caches, their creation and usage methods, and billing details.
Features
Before running a container, Elastic Container Instance (ECI) must pull the specified container image. The image pull is often the most time-consuming part of an ECI instance's startup, and its duration depends on factors like network conditions and image size. To accelerate instance creation, ECI provides the image cache feature. You can pre-build required images into a cache snapshot. When you create ECI instances from this snapshot, you avoid or reduce the download of image layers, significantly speeding up instance creation.
Tests show that when creating an ECI instance with the flink image (approximately 386.26 MB) from Docker Hub, the image preparation phase normally takes 50 seconds. Using an image cache eliminates this preparation time, significantly reducing the instance startup time.
The actual speed improvement depends on factors such as the number and size of the container images used in the ECI instance and the network conditions of the image registry.
Creation methods
You can create an image cache in two ways: manual and automatic.
We recommend that you use automatic creation to reduce costs. However, to accelerate the creation of the first ECI instance, you must create an image cache manually beforehand.
Manual creation
You can create an image cache by configuring parameters such as its name and size. The process is as follows:
Each image cache corresponds to a snapshot. You are responsible for managing the snapshots of manually created image caches.
During the creation process, the system creates a temporary ECI instance (2 vCPU, 4 GiB of memory) and attaches an ESSD PL1 cloud disk to create the image cache's snapshot. After the creation is complete, the temporary instance and cloud disk are automatically released.
The instant image cache feature shortens the creation time of an image cache. If you enable this feature, the system enables instant snapshot availability and temporarily creates a local snapshot. You can start using the image cache as soon as the local snapshot is created.
NoteAfter the local snapshot is created, the system automatically begins to create a standard snapshot. During this time, the image cache is backed by the local snapshot. After the standard snapshot is ready, the system automatically deletes the local snapshot, and the image cache is then backed by the standard snapshot.
The image cache reuse feature speeds up the creation of image caches. If you enable this feature, the system automatically finds existing image caches that have matching image layers. The new image cache reuses these layers instead of re-downloading them, which accelerates the creation process.
Automatic creation
When you create an ECI instance with automatic image cache matching enabled, the system automatically creates an image cache if no matching cache is found. The process is as follows:
Each image cache corresponds to a snapshot. Alibaba Cloud manages the snapshots of automatically created image caches.
During the creation process, the system creates an ECI instance and uses the ephemeral storage of the instance to create the snapshot for the image cache. After the creation is complete, the instance is automatically released.
NoteBy default, each ECI instance has 30 GiB of ephemeral storage available for creating image caches. If your images exceed 30 GiB in total size, you must declare additional ephemeral storage. For more information, see Increase the ephemeral storage size of an ECI instance.
Comparison
Manually created and automatically created image caches differ in aspects such as size and retention period. The following table compares the two methods.
Item | Manual creation | Automatic creation |
Name | You can specify a custom name. | The system automatically generates the name in the format |
Size | The default size is 20 GiB. You can specify a custom size. | The default size is 30 GiB. If you declare additional ephemeral storage when you create the ECI instance, the image cache size is 30 GiB plus the size of the ephemeral storage. |
Retention period | By default, the cache is permanent. You can set a custom retention period in days. The cache is automatically deleted after the retention period expires. | By default, Alibaba Cloud manages the retention period.
|
Image cache reuse | You can enable image cache reuse to reuse existing image layers and accelerate the creation of the image cache. | Not supported. |
Instant image cache | You can enable instant image cache to create a temporary local snapshot and shorten the creation time of the image cache. | Not supported. |
Quota | You can call the ListUsage API operation or view your quota on the Privileges and Quotas page in the console. If the quota is insufficient, you can submit a ticket to request a quota increase. | You can call the ListUsage API operation to view your quota. If the quota is insufficient, you can submit a ticket to request a quota increase. |
Eviction policy | By default, you cannot manually create more image caches after you reach your quota. You can use the | When the quota is reached, the system automatically deletes the least recently used (LRU) image cache. |
Cost | You are charged for creation and usage. | You are charged only for usage, not for creation. |
Usage methods
Using an image cache accelerates the creation of ECI instances. When you create an ECI instance, you can use an image cache in one of the following two ways:
Method | Description |
Automatic matching | The system automatically selects the optimal image cache. The matching process is as follows:
Note If no matching image cache is found, the system automatically creates one while the ECI instance is being created. During this process, images are pulled as normal. We recommend that you set the image pull policy of your container to |
Manual specification | Specify the exact image cache to use. The specified image cache must be in the Ready state. |
Notes
A single image cache can contain a maximum of 20 container images.
Creating an image cache requires pulling container images. Therefore, the creation time varies depending on factors such as the number and size of the images and network conditions.
Manually created image caches use the container images that you specify. Automatically created image caches use the container images that are declared in the instance.
If you use a private image that is not hosted in Alibaba Cloud Container Registry (ACR), you must provide the access credentials for the private image registry, including the address, username, and password.
If images need to be pulled over the public network, such as official Docker images, you must configure an Elastic IP Address (EIP) or a NAT gateway to enable public network access. For more information, see Connect an ECI instance to the public network.
If image pulls fail due to issues such as a remote registry timeout, we recommend that you use Alibaba Cloud Container Registry (ACR) and push the images to a registry hosted on Alibaba Cloud.
For manually created image caches, we recommend setting a retention period to avoid unnecessary snapshot fees. For automatically created image caches, Alibaba Cloud manages the corresponding snapshots, so you do not need to configure a retention period.
After an image cache is created, you can view its creation events to understand the creation process. The system retains the 50 most recent creation events.
Billing
Phase | Manual cache | Automatic cache |
Image cache creation | The following items are billed:
| Free of charge |
Image cache usage | Cloud disk fees | If the image cache is larger than 30 GiB, you must add and pay for additional ephemeral storage. |
For more information, see Image cache billing.