Creates an image cache. Image caches can accelerate image pulls and reduce instance startup time when you create an elastic container instance.

Description

  • Precautions
    • You are charged for creation of image caches. We recommend that you learn the relevant billing information in advance. For more information, see Billing.
    • Before you create an image cache, you must estimate the total size of the images that you want to cache. 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 intermediate instance and the ESSD while the image cache is being created. If you delete the intermediate instance or the ESSD, the image cache cannot be created.
    • A temporary local snapshot and a specific number of regular snapshots are generated during the creation of the image cache. Do not delete these snapshots. If you delete these snapshots, the image cache becomes invalid.
    • If you use SDKs, SDK for Java 1.0.10 or later and SDK for Python 1.0.7 or later are supported.
  • Usage notes
    • You can configure AcrRegistryInfo-related parameters to pull images from Container Registry Enterprise Edition instances without using a password. When you use AcrRegistryInfo-related parameters to pull images from a Container Registry Enterprise Edition instance without using a password, you must specify the AcrRegistryInfo.N.InstanceId parameter.
    • If the image cache that you created will be used to create more than 1,000 elastic container instances at a time, we recommend that you use the StandardCopyCount and FlashCopyCount parameters to create multiple temporary local snapshots and regular snapshots for the image cache. The multiple snapshots are billed based on incremental data. If no incremental data exists on the multiple snapshots, you are not charged for the multiple snapshots.
Note When you call the CreateImageCache operation to create an image cache, the system automatically creates a service-linked role named AliyunServiceRoleForECI. The role is used 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 Yes CreateImageCache

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

RegionId String Yes cn-hangzhou

The region ID of the image cache.

ZoneId String No cn-hangzhou-g

The zone ID of the image cache.

SecurityGroupId String Yes sg-uf66jeqopgqa9hdn****

The ID of the security group.

VSwitchId String Yes vsw-uf6h3rbwbm90urjwa****

The ID of the vSwitch.

ImageCacheName String Yes testcache

The name of the image cache.

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 access the Internet.

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 ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

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 deleted. By default, image caches never expire.

Note The image caches that fail to be created are only retained for one day.
AutoMatchImageCache Boolean No true

Specifies whether to enable reuse of image cache layers. If you enable this feature, and the image cache that you want to create and an existing image cache contain duplicate image layers, the system reuses the duplicate image layers to create the new image cache. This accelerates the creation of the image cache. Valid values:

  • true: enables reuse of image cache layers.
  • false: disables reuse of image cache layers.

Default value: false.

Flash Boolean No true

Specifies whether to enable instant image cache. After you enable the feature, image caches can be created in an accelerated manner. Valid values:

  • true: enables instant image cache.
  • false: disables instant image cache.

Default value: false.

Note The system automatically generates a temporary local snapshot for the image cache during the use of the instant image cache feature. You are charged for the instant use of the snapshot.
Annotations String No hide

Comments.

PlainHttpRegistry String No "harbor***.pre.com,192.168.XX.XX:5000,reg***.test.com:80"

The domain name of the self-managed image repository. When you create an image cache by using an image in a self-managed image repository that uses the HTTP Protocol, you must specify this parameter. This way, Elastic Container Instance uses the HTTP protocol to pull the image. This can prevent the image from failing to pull due to different protocols.

InsecureRegistry String No "harbor***.pre.com,192.168.XX.XX:5000,reg***.test.com:80"

The domain name of the self-managed image repository.

When you create an image cache by using an image in a self-managed image repository that uses a self-signed certificate, you must specify this parameter to skip the certificate authentication. This can prevent the image from failing to pull due to certificate authentication failures.

StandardCopyCount Integer No 7

The number of regular snapshots. By default, the system creates one snapshot for each image cache. If an image cache is used to create multiple elastic container instances at a time, we recommend that you set this parameter to create multiple snapshots for the image cache. We recommend that you create one snapshot for creation of every 1,000 elastic container instances.

Note If you set the Flash parameter to false, instant image cache is disabled. In this case, only regular snapshots are generated during the creation of the image cache.
FlashCopyCount Integer No 7

The number of temporary local snapshots. By default, the system creates one snapshot for each image cache. If an image cache is used to create multiple elastic container instances at a time, we recommend that you set this parameter to create multiple snapshots for the image cache. We recommend that you create one snapshot for creation of every 1,000 elastic container instances.

Note If you set the Flash parameter to true, instant image cache is enabled. During the creation of the image cache, the system first creates a temporary local snapshot for you to instantly use the snapshot. After the temporary local snapshot is created, the system begins to create a regular snapshot. After the regular snapshot is created, the temporary local snapshot is automatically deleted.
ImageRegistryCredential.N.Password String No password

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

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

The endpoint of the image repository.

ImageRegistryCredential.N.UserName String No username

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

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

Container image N that is used to create the image cache.

Tag.N.Key String No imc

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

Tag.N.Value String No test

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

AcrRegistryInfo.N.Domain.N String No test****-registry.cn-beijing.cr.aliyuncs.com

Domain name N of Container Registry Enterprise Edition instance N. All domain names of instance N are displayed by default. You can specify domain names. Separate multiple domain names with commas (,).

AcrRegistryInfo.N.InstanceName String No test****

The name of Container Registry Enterprise Edition instance N.

AcrRegistryInfo.N.InstanceId String No cri-nwj395hgf6f3****

The ID of Container Registry Enterprise Edition instance N.

AcrRegistryInfo.N.RegionId String No cn-beijing

The region ID of Container Registry Enterprise Edition instance N.

Response parameters

Parameter Type Example Description
RequestId String 0E234675-3465-4CC3-9D0F-9A864BC391DD

The ID of the request.

ImageCacheId String imc-2zebxkiifuyzzlhl****

The ID of the image cache.

ContainerGroupId String eci-2zebxkiifuyzzlhl****

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

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

HTTP/1.1 200 OK
Content-Type:application/xml

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

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "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 vCPU and memory specifications are invalid.
400 IncorrectStatus %s The error message returned because the status of the specified instance is invalid.
400 ServiceNotEnabled %s The error message returned because the service that is 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 disk volumes are not supported. If you want to use disk volumes, 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 current zone.
403 QuotaExceeded %s quota exceeded. The error message returned because the maximum number of elastic container instances allowed is reached.
403 Zone.NotOnSale The specified zone is not available for purchase. The error message returned because the specified zone is unavailable for purchase of the instance or because the vSwitches in the specified VPC cannot be used in the current 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 are not allowed to perform the operation.
403 InvalidUser.PassRoleForbidden The RAM user is not authorized to assume a RAM role. The error message returned because the RAM user is not authorized to assume the 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 in the current zone. Try other regions, zones or instance types. To ensure that available resources are sufficient, we recommend that you specify multiple zones and instance types. For more information, visit https://www.alibabacloud.com/help/doc-detail/157290.html.
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 URL 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.