All Products
Search
Document Center

Elastic Container Instance:CreateImageCache

更新時間:Nov 14, 2024

Creates an image cache. The image cache can accelerate image pulling and reduce the instance startup time when you create an elastic container instance later.

Operation description

  • Precautions

    • You are charged for creation of image caches. We recommend that you learn the relevant billing information in advance. For more information about billing of image caches, see Image caches.
    • 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

    • For images that are created based on Container Registry Enterprise Edition instances and use custom domain names, if you want to configure password-free access to the image caches, you must use AcrRegistryInfo-related parameters to specify Container Registry instances. When you configure AcrRegistryInfo-related parameters, you must set 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 of the image. 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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
eci:CreateImageCachecreate
*ImageCache
acs:eci:{#regionId}:{#accountId}:imagecache/*
  • eci:tag
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the image cache.

cn-hangzhou
ZoneIdstringNo

The zone ID of the image cache.

cn-hangzhou-g
SecurityGroupIdstringYes

The ID of the security group.

sg-uf66jeqopgqa9hdn****
VSwitchIdstringYes

The ID of the vSwitch. You can specify up to 10 vSwitch IDs. Separate multiple vSwitch IDs with commas (,). Example: vsw-***,vsw-***.

vsw-uf6h3rbwbm90urjwa****
ImageCacheNamestringYes

The name of the image cache.

testcache
EipInstanceIdstringNo

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.

eip-2zedsm5mfl3uhdj2d****
ResourceGroupIdstringNo

The ID of the resource group.

rg-aekzh43v*****
ClientTokenstringNo

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 the value 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 the idempotence of a request.

123e4567-xxx-xxx-xxxx-42665544xxxx
ImageCacheSizeintegerNo

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

20
RetentionDaysintegerNo

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.
7
AutoMatchImageCachebooleanNo

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.

true
ImageRegistryCredentialarray<object>No

The image repository.

objectNo

The image repository.

PasswordstringNo

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

password
ServerstringNo

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

registry-vpc.cn-hangzhou.aliyuncs.com
UserNamestringNo

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

username
ImagearrayYes

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

stringYes

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

registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:1.15.10-perl
Tagarray<object>No

The tag of the image cache.

objectNo

The tag of the image cache.

KeystringNo

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

imc
ValuestringNo

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

test
FlashbooleanNo

Specifies whether to enable the instant image cache feature. The feature can accelerate the creation of image caches. Valid values:

  • true
  • false

Default value: false.

true
AcrRegistryInfoarray<object>No

Information about the Container Registry Enterprise Edition instance. For more information, see Pull images from a Container Registry Enterprise Edition instance without using secrets.

objectNo

Information about the Container Registry Enterprise Edition instance. For more information, see Pull images from a Container Registry Enterprise Edition instance without using secrets.

DomainarrayNo

The domain names of the Container Registry Enterprise Edition instance. By default, all domain names of the instance are displayed. You can specify multiple domain names. Separate multiple domain names with commas (,).

stringNo

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

test****-registry.cn-beijing.cr.aliyuncs.com
InstanceNamestringNo

The name of Container Registry Enterprise Edition instance N.

test****
InstanceIdstringNo

The ID of Container Registry Enterprise Edition instance N.

cri-nwj395hgf6f3****
RegionIdstringNo

The region ID of Container Registry Enterprise Edition instance N.

cn-beijing
ArnServicestringNo

The Alibaba Cloud Resource Name (ARN) of the RAM roles in the Alibaba Cloud account to which the elastic container instance belongs.

acs:ram::1609982529******:role/role-assume
ArnUserstringNo

The ARN of the RAM roles in the Alibaba Cloud account to which the Container Registry Enterprise Edition instance belongs.

acs:ram::1298452580******:role/role-acr
AnnotationsstringNo

Comments.

hide
PlainHttpRegistrystringNo

The address 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 instead of the default HTTPS protocol to pull the image. This can prevent the image from failing to pull due to different protocols.

"harbor***.pre.com,192.168.XX.XX:5000,reg***.test.com:80"
InsecureRegistrystringNo

The address 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.

"harbor***.pre.com,192.168.XX.XX:5000,reg***.test.com:80"
StandardCopyCountintegerNo

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.
7
FlashCopyCountintegerNo

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.
7
EliminationStrategystringNo

The elimination policy of the image cache. This parameter is empty by default, which indicates that the image cache is always retained.

You can set this parameter to LRU, which indicates that the image cache can be automatically deleted. When the number of image caches reaches the quota, the system automatically deletes the image caches whose EliminationStrategy parameter is set to LRU and that are least commonly used.

LRU

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

0E234675-3465-4CC3-9D0F-9A864BC391DD
ImageCacheIdstring

The ID of the image cache.

imc-2zebxkiifuyzzlhl****
ContainerGroupIdstring

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

eci-2zebxkiifuyzzlhl****

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400Account.ArrearageYour account has an outstanding payment.Your account has an outstanding payment.
400DryRunOperationRequest validation has been passed with DryRun flag set.Request validation has been passed with DryRun flag set.
400InvalidParameter.CPU.MemoryThe specified cpu and memory are not allowed-
400IncorrectStatus%s-
400ServiceNotEnabled%sYou have not activated the service that is required for processing this request.
400DiskVolume.NotSupportThe disk volume is not supported.Disk volume does not support your structure. If you want to enable this function, contact us.
400RamRole.NotSupportThe RAM role is not supported.The RAM role is not supported.
400ImageCache.IncorrectStatus%s-
400ImageCacheNotSupportImage cache is not available for all users. If you want to enable this function, contact us.Container image cache is currently not available to all users. Submit a ticket if you need to use the feature.
400EipAddressPoolIpNotEnoughThe ip address of specified PublicIpAddressPool is not enough.-
400OperationConflictThe request was denied. It conflicts with a previous request.-
403OperationDenied.VswZoneMisMatchThe specified VSwitchId is not in the specified Zone.-
403QuotaExceeded%s quota exceeded.-
403Zone.NotOnSaleThe specified zone is not available for purchase.-
403Forbidden.RiskControlThis operation has been identified as an abnormal operation and cannot be processed.-
403Forbidden.SubUserThe specified action is not available for you.The specified action is not available for you.
403Forbidden.OnlyForInvitedTestEci create action is only open to invited users during public beta.Eci create action is only open to invited users during public beta.
403OperationDenied.SecurityGroupMisMatchThe specified VSwitchId and SecurityGroupId are not in the same VPC.The specified VSwitchId and SecurityGroupId are not in the same VPC.
403InvalidVSwitchId.IpNotEnoughThe specified VSwitch does not have enough IP addresses.-
403Forbidden.UserBussinessStatusThis operation is not allowed, because you have overdue bills. Pay the overdue bill and try again.-
403Forbidden.UserNotRealNameAuthenticationThis operation is not allowed, because you have not passed the real-name verification.-
403InvalidUser.PassRoleForbiddenThe RAM user is not authorized to assume a RAM role.The RAM user is not authorized to assume a RAM role.
403OperationDenied.NoStockSales 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-
403NoPermissionThe RAM role AliyunECIContainerGroupRole does not belong to eci.aliyuncs.com. Please check and try again.-
403SecurityRisk.3DVerificationWe have detected a security risk with your default credit or debit card. Please proceed with verification via the link in your email.-
403CreateServiceLinkedRole.DeniedPlease make sure the account has ram:CreateServiceLinkedRole permission.Please make sure the account has ram:CreateServiceLinkedRole permission.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-09-26The Error code has changed. The request parameters of the API has changedView Change Details
2023-08-02The Error code has changedView Change Details
2023-06-27The Error code has changedView Change Details
2022-03-01The Error code has changed. The request parameters of the API has changedView Change Details
2022-03-01The Error code has changed. The request parameters of the API has changedView Change Details
2021-09-10The Error code has changed. The request parameters of the API has changedView Change Details
2021-08-12The Error code has changed. The request parameters of the API has changedView Change Details