To run containers, Elastic Container Instance (ECI) needs to pull the specified images. However, pulling large-sized images over an unstable network is time-consuming when you start ECIs. To resolve this issue, you can use the image cache feature.

To use the image cache feature, follow these steps:

  1. Create an image cache.
  2. Query the image cache.
  3. Create an ECI by using the image cache.

Billing

You are charged for creating and using image caches.

Fees of creating an image cache

After you submit the request for creating an image cache, Alibaba Cloud uses 1 vCPU and 2 GiB memory of ECI resources to create an image cache. To create an image cache, you need to pay the following fees:
  • The fee of 1 vCPU and 2 GiB memory. The billing stops after the image cache is created. For more information, see Billing.
  • The fee of the disk used for storing image snapshots. The default disk is an enhanced solid-state disk (ESSD) PL1 with 20 GiB memory. You can customize the size of the disk. The minimum size is 20 GiB. For more information about the price of disks, see .
  • The fee of an image snapshot. An image snapshot is generated each time you create an image cache. For more information, see Snapshot billing methods.

You can log on to the ECI console to view the created image cache.

Fees of using an image cache

If you use an image cache to create an ECI, a disk created for storing image snapshots is mounted to the ECI. For more information, see Billing.

Assume that you want to create an ECI in the China (Beijing) region. The ECI needs an ESSD PL1 with 20 GiB memory to store image snapshots. You need to pay CNY 0.04 per hour for the disk.

Create an image cache

  • By default, an ECI with 1 vCPU and 2 GiB memory is used to create an image cache. A fee will be generated during the creation.
  • Currently, an image cache can contain up to 20 images. You can customize the size of the image cache. The default size is 20 GiB.
  • You can set the retention period for the image cache. The image cache is automatically deleted after it expires. By default, the retention period is not specified. You can specify the retention period if needed.
  • If you select private images that are not hosted by Alibaba Cloud Container Registry, specify the address, username, and password of the private image repository. ECI needs the information to pull images from the private image repository.
  • If ECI needs to pull the selected images over the Internet, such as Docker images, you must enable Internet access for ECIs. For more information, see Enable Internet access.

Create an image cache in the ECI console

You can create an image cache in the ECI console through simple operations.

Create an image cache by using an API operation

You can view and debug the API operation used to create an image cache in OpenAPI Explorer.

Parameter description:
ImageCacheName=normalimage // The name of the image cache.
Image.1=registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.15.10
Image.2=registry-vpc.cn-beijing.aliyuncs.com/eci_open/node:11
Image.3=registry-vpc.cn-beijing.aliyuncs.com/eci_open/mysql:5.6
RetentionDays=30 // The retention period of the image cache. Valid values: 1 to 65536. Unit: days.
ImageCacheSize=20 // The size of the image cache. Valid values: 20 to 500. Default value: 20. Unit: GiB.

Query the image cache

You can view and debug the API operation used to query an image cache in OpenAPI Explorer.

Sample response:

{
	"ImageCaches": [
		{
			"CreationTime": "2019-12-18T03:18:02Z",
			"Status": "Ready",
			"ContainerGroupId": "eci-2zehl84ra0em1rzvku1f",
			"ImageCacheId": "imc-2zehl84ra0em1rzvku1f", // The ID of the image cache.
			"ImageCacheName": "normalimage",
			"Events": [...
			],
			"SnapshotId": "s-2ze10h8c369eb7spa2oe",
			"Images": [
				"registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.15.10",
				"registry-vpc.cn-beijing.aliyuncs.com/eci_open/node:11",
				"registry-vpc.cn-beijing.aliyuncs.com/eci_open/mysql:5.6"
			],
			"ExpireDateTime": "2020-01-17T20:49:47Z", // The time when the image cache expires.
			"Progress": "100%" // The percentage of the creation progress.
		}
	],
	"RequestId": "1ABEBF6E-6780-49CA-8C34-EEC6017F3012"
}

Create an ECI by using the image cache

You can use the image cache to create an ECI in one of the following ways:

  • Specify an image cache.
  • Enable automatic image cache match. ECI automatically selects and uses the optimal image cache.
You can view and debug the API operation used to create an ECI in OpenAPI Explorer.
Notice When you create an ECI by using the image cache, set the ImagePullPolicy parameter to IfNotPresent for the containers. Otherwise, the effect of using an image cache to accelerate ECI creation will be greatly affected.
Specify an image cache
ImageSnapshotId=imc-2zehl84ra0em1rzvku1f
Enable automatic image cache match
AutoMatchImageCache=true

Verify the result in the ECI console

View the events of the ECI in the ECI console.

The ECI is created from existing images. No time is spent in pulling images from a remote image repository.

For more information about how to use the image cache feature in Alibaba Cloud Container Service for Kubernetes, see Use an image cache CRD to accelerate pod creation.