You can call this operation to create an image cache. You can use an image cache to create an elastic container instance to accelerate image pulling and reduce the startup time.

Description

  • Before you create an image cache, you must evaluate the size of the image to be cached. If the image size exceeds the specified cache size, the image cache fails to be created.
  • When an image cache is being created, the system creates an elastic container instance and a PL1 enhanced SSD (ESSD) for intermediation. Do not delete the elastic container instance and the ESSD when the image cache is being created. Otherwise, the image cache fails to be created. After the image cache is created, the instance and the ESSD are automatically released and stop billing.
  • 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 is invalid.
  • If you use SDK, the valid version is Java 1.0.10 or later and Python 1.0.7 or later.

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.

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 make 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 zone ID of the image cache.

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

The address of image repository N without http:// or https:// as prefix.

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 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, you must 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.

ImageCacheSize Integer No 20

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

RetentionDays Integer No 7

The retention days of the image cache. After the image cache expires, it is removed. By default, the image cache never expires.

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 ensure the idempotence of the request. You can use the client to generate the value, but you must make sure 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.

Tag.N.Key String No imc

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

Tag.N.Value String No test

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

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 new image caches. This can accelerate the creation of image caches.

Response parameters

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

The ID of the elastic container instance used for intermediation when the image cache is being created.

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 your account has an overdue payment.
400 DryRunOperation Request validation has been passed with DryRun flag set. The error message returned because the specified dry run passed.
400 InvalidParameter.CPU.Memory The specified cpu and memory are not allowed The error message returned because the CPU and memory specifications are invalid.
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 the vSwitch of the specified VPC is 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 identified as an anomaly and cannot be processed.
403 Forbidden.SubUser The specified action is not available for you. The error message returned because you are not authorized to perform the specified 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.
400 IncorrectStatus %s The error message returned because the status of the specified elastic container instance is invalid.
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. Complete 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 specified operation is not allowed.
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 as a volume is not supported. If the problem persists, contact Alibaba Cloud customer service.
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 permission to assume the RAM role.
400 RamRole.NotSupport The RAM role is not supported. The error message returned because the specified RAM role is not supported.
400 ImageCache.IncorrectStatus %s The error message returned because the status of the specified 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 customer service.
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 the resources are insufficient. Try another region or other instance types. To avoid creation failures, we recommend that you specify multiple zones and instance types. For more information, see https://help.aliyun.com/document_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 link in the email for verification.

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