Creates an image cache. You can use an image cache to create an elastic container instance to accelerate the image pulling process and reduce the startup time.

Description

  • Before you create an image cache, you must evaluate the total size of the images to be cached. If the total size of the images exceeds the specified cache size, the image cache cannot be created.
  • When an image cache is being created, the system creates an intermediate elastic container instance and an intermediate enhanced SSD (ESSD) at performance level 1 (PL1). Do not delete the instance and the ESSD while the image cache is being created. Otherwise, the image cache cannot be created. After the image cache is created, the instance and the ESSD are automatically released and no longer billed.
  • After an image cache is created, the system generates a snapshot for the image cache. You are charged for the snapshot. Do not delete the snapshot. Otherwise, the image cache becomes invalid.
  • If you use SDK, Java 1.0.10 or later and Python 1.0.7 or later are supported.
  • If you enable the instant image cache feature, you are charged for the created instant snapshot.
Note When you call the CreateImageCache operation to create an image cache, the system creates a service-linked role named AliyunServiceRoleForECI for Elastic Container Instance to access other Alibaba Cloud services such as Elastic Compute Service (ECS) and Virtual Private Cloud (VPC). For more information, see Elastic Container Instance service-linked role.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No CreateImageCache

The operation that you want to perform. Set the value to CreateImageCache.

RegionId String Yes cn-hangzhou

The ID of the region in which to create the image cache.

ImageCacheName String Yes testcache

The name of the image cache.

Image.N RepeatList Yes registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.15.10-perl

Image N used to create the image cache.

SecurityGroupId String Yes sg-uf66jeqopgqa9hdn****

The ID of the security group.

VSwitchId String Yes vsw-uf6h3rbwbm90urjwa****

The ID of the vSwitch.

ZoneId String No cn-hangzhou-g

The ID of the zone.

ImageRegistryCredential.N.Server String No registry-vpc.cn-hangzhou.aliyuncs.com

The URL of image repository N, from which http:// and https:// are absent.

ImageRegistryCredential.N.UserName String No username

The username that is used to log on to image repository N.

ImageRegistryCredential.N.Password String No password

The password that is used to log on to image repository N.

EipInstanceId String No eip-2zedsm5mfl3uhdj2d****

The ID of the elastic IP address (EIP). If you want to pull images over the Internet, make sure that the elastic container instance can access the Internet. You can configure an EIP or a NAT gateway for the elastic container instance to enable Internet access.

ImageCacheSize Integer No 20

The size of the image cache. Unit: GiB. Default value: 20.

RetentionDays Integer No 7

The retention period of the image cache. Unit: days. When the retention period ends, the image cache expires and is automatically deleted. By default, image caches never expire.

Note The image cache that fails to be created is retained for only one day.
ResourceGroupId String No rg-aekzh43v*****

The ID of the resource group.

ClientToken String No 123e4567-xxx-xxx-xxxx-42665544xxxx

The client token that is used to guarantee the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

AutoMatchImageCache Boolean No true

Specifies whether to enable image cache reuse. After the feature is enabled, the image layers of existing image caches can be used to create image caches. This can accelerate the creation of image caches. Valid values:

  • true: enables image cache reuse.
  • false: does not enable image cache reuse.

Default value: false.

Flash Boolean No true

Specifies whether to enable instant image cache. After the feature is enabled, it can accelerate the creation of image caches. Valid values:

  • true: enables instant image cache.
  • false: does not enable instant image cache.

Default value: false.

Tag.N.Key String No imc

The tag key to add to the image cache. Valid values of N: 1 to 20.

Tag.N.Value String No test

The tag value to add to the image cache. Valid values of N: 1 to 20.

Response parameters

Parameter Type Example Description
ContainerGroupId String eci-2zebxkiifuyzzlhl****

The ID of the intermediate elastic container instance used to create the image cache.

ImageCacheId String imc-2zebxkiifuyzzlhl****

The ID of the image cache.

RequestId String 0E234675-3465-4CC3-9D0F-9A864BC391DD

The ID of the request.

Examples

Sample requests

https://eci.aliyuncs.com/?Action=CreateImageCache
&RegionId=cn-hangzhou
&ImageCacheName=testcache
&Image.1=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.15.10-perl
&SecurityGroupId=sg-uf66jeqopgqa9hdn****
&VSwitchId=vsw-uf6h3rbwbm90urjwa****
&<Common request parameters>

Sample success responses

XML format

<CreateImageCacheResponse>
      <ImageCacheId>imc-2zebxkiifuyzzlhl****</ImageCacheId>
      <RequestId>0E234675-3465-4CC3-9D0F-9A864BC391DD</RequestId>
      <ContainerGroupId>eci-2zebxkiifuyzzlhl****</ContainerGroupId>
</CreateImageCacheResponse>

JSON format

{
	"ImageCacheId": "imc-2zebxkiifuyzzlhl****",
	"RequestId": "0E234675-3465-4CC3-9D0F-9A864BC391DD",
	"ContainerGroupId": "eci-2zebxkiifuyzzlhl****"
}

Error codes

HTTP status code Error code Error message Description
400 Account.Arrearage Your account has an outstanding payment. The error message returned because you have an overdue payment in your account.
400 DryRunOperation Request validation has been passed with DryRun flag set. The error message returned because the request is determined as valid in the dry run.
400 InvalidParameter.CPU.Memory The specified cpu and memory are not allowed The error message returned because the CPU and memory specifications are invalid.
400 IncorrectStatus %s The error message returned because the status of the specified elastic container instance is invalid.
400 ServiceNotEnabled %s The error message returned because the service required to call the operation is not activated. Activate the service and try again later.
400 DiskVolume.NotSupport The disk volume is not supported. The error message returned because the disk cannot be used as a volume. If the error persists, contact Alibaba Cloud technical support personnel.
400 RamRole.NotSupport The RAM role is not supported. The error message returned because the specified Resource Access Management (RAM) role is not supported.
400 ImageCache.IncorrectStatus %s The error message returned because the status of the image cache is invalid.
400 ImageCacheNotSupport Image cache is not available for all users. If you want to enable this function, contact us. The error message returned because the image cache feature is not available to all users. If you need to use this feature, contact Alibaba Cloud technical support personnel.
403 OperationDenied.VswZoneMisMatch The specified VSwitchId is not in the specified Zone. The error message returned because the specified vSwitch is not deployed in the specified zone.
403 QuotaExceeded %s quota exceeded. The error message returned because the maximum number of elastic container instances has been reached.
403 Zone.NotOnSale The specified zone is not available for purchase. The error message returned because the specified zone is unavailable or because the vSwitches of the specified VPC are unavailable in the specified zone. Specify another zone.
403 Forbidden.RiskControl This operation has been identified as an abnormal operation and cannot be processed. The error message returned because the operation is determined as abnormal and cannot be performed.
403 Forbidden.SubUser The specified action is not available for you. The error message returned because you are not authorized to perform the operation.
403 Forbidden.OnlyForInvitedTest Eci create action is only open to invited users during public beta. The error message returned because Elastic Container Instance is available only to invited users during the public preview period.
403 OperationDenied.SecurityGroupMisMatch The specified VSwitchId and SecurityGroupId are not in the same VPC. The error message returned because the specified vSwitch and security group are not deployed in the same VPC.
403 InvalidVSwitchId.IpNotEnough The specified VSwitch does not have enough IP addresses. The error message returned because the vSwitch does not have sufficient IP addresses.
403 Forbidden.UserBussinessStatus This operation is not allowed, because you have overdue bills. Pay the overdue bill and try again. The error message returned because you have an overdue payment. Settle the overdue payment and try again later.
403 Forbidden.UserNotRealNameAuthentication This operation is not allowed, because you have not passed the real-name verification. The error message returned because you have not completed real-name verification and the operation is not allowed.
403 InvalidUser.PassRoleForbidden The RAM user is not authorized to assume a RAM role. The error message returned because RAM users do not have the permissions to assume a RAM role.
403 OperationDenied.NoStock Sales of this resource are temporarily suspended in the specified zone. We recommend that you use the multi-zone creation function to avoid the risk of insufficient resource. For more information, see https://help.aliyun.com/document_detail/157290.html The error message returned because available resources are insufficient. Try another region or other instance types. To ensure that available resources are sufficient, we recommend that you specify multiple zones and instance types. For more information, see https://www.alibabacloud.com/help/doc-detail/157290.htm.
403 NoPermission The RAM role AliyunECIContainerGroupRole does not belong to eci.aliyuncs.com. Please check and try again. The error message returned because the AliyunECIContainerGroupRole RAM role does not belong to eci.aliyuncs.com. Check and try again.
403 SecurityRisk.3DVerification We have detected a security risk with your default credit or debit card. Please proceed with verification via the link in your email. The error message returned because risks are detected in your default credit card or debit card. Click the link in the email for verification.
403 CreateServiceLinkedRole.Denied Please make sure the account has ram:CreateServiceLinkedRole permission. The error message returned because you do not have the ram:CreateServiceLinkedRole permission.

For a list of error codes, visit the API Error Center.