调用CreateContainerGroup创建一个容器组(ECI实例)。

接口说明

调用CreateContainerGroup创建ECI实例时,系统将自动为您创建一个服务关联角色AliyunServiceRoleForECI,用于访问ECS、VPC等相关云服务。更多信息,请参见弹性容器实例服务关联角色

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateContainerGroup

系统规定参数。取值:CreateContainerGroup

Container.N.Image String registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest

容器镜像。

Container.N.Name String nginx

容器镜像名称。

ContainerGroupName String nginx-test

容器组名称。

RegionId String cn-hangzhou

创建实例的地域。

SecurityGroupId String sg-uf66jeqopgqa9hdn****

指定新创建实例所属于的安全组代码,同一个安全组内的实例之间可以互相访问。

VSwitchId String vsw-uf6h3rbwbm90urjwa****

指定虚拟交换机 ID。当前 ECI 实例均为 VPC 实例。

交换机网段内IP的个数决定了该交换机最大可创建的 ECI 实例数,请务必提前规划好网段设置。

ZoneId String cn-hangzhou-b

实例所属的可用区编号,空表示由系统选择,默认值:空。

RestartPolicy String Always

实例重启策略: Always(总是重启)、Never(从不重启)、OnFailure(失败时重启),默认:Always

EipInstanceId String eip-uf66jeqopgqa9hdn****

弹性公网IP ID。

Cpu Float 1.0

CPU 大小。

Memory Float 2.0

内存大小。

ResourceGroupId String rg-uf66jeqopgqa9hdn****

资源组ID。

DnsPolicy String Default

DNS策略。

ClientToken String 123e4567-xxxx-12d3-xxxx-426655440000

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。只支持ASCII字符,且不能超过64个字符。更多详情,请参阅如何保证幂等性

InstanceType String ecs.c5.xlarge

实例规格,支持多规格。

SlsEnable Boolean false

开启用户日志收集,默认为False

ImageSnapshotId String imc-2zebxkiifuyzzlhl****

镜像缓存ID。

RamRoleName String RamTestRole

实例RAM角色名称,ECI与ECS共用实例RAM角色,使用方式请参阅通过API使用实例RAM角色

TerminationGracePeriodSeconds Long 60

给程序留的最后缓冲时间,来处理关闭之前的操作。

AutoMatchImageCache Boolean false

自动匹配镜像缓存。

Ipv6AddressCount Integer 128

Ipv6地址数。

ActiveDeadlineSeconds Long 1000

有效期限秒。

SpotStrategy String SpotPriceLimit

实例的抢占策略。

取值范围:

NoSpot(默认):正常按量付费实例。

SpotWithPriceLimit:设置上限价格的抢占式实例。

SpotAsPriceGo:系统自动出价,跟随当前市场实际价格。

SpotPriceLimit Float 0.025

设置实例的每小时最高价格。支持最大 3 位小数,参数 SpotStrategy 取值为 SpotWithPriceLimit 时生效。

AutoCreateEip Boolean true

自动创建Eip绑定容器组。

EipBandwidth Integer 5

绑定EIP指定带宽。默认为5M。

HostName String test

主机名称(容器组名称)。

IngressBandwidth Long 1024000

入方向带宽限制,单位:Byte

EgressBandwidth Long 1024000

出方向带宽限制,单位:Byte

CpuOptionsCore Integer 2

CPU物理核心数。仅部分规格支持自定义设置。更多信息,请参见自定义CPU选项

CpuOptionsThreadsPerCore Integer 2

每核线程数。仅部分规格支持自定义设置。配置为1时表示关闭超线程。更多信息,请参见自定义CPU选项

EphemeralStorage Integer 20

临时存储空间大小,默认使用ESSD PL1类型的云盘。单位为:GiB。

Tag.N.Key String version

标签键。

Tag.N.Value String 3

标签值。

ImageRegistryCredential.N.Password String yourpaasword

镜像仓库密码。

ImageRegistryCredential.N.Server String registry-vpc.cn-shanghai.aliyuncs.com

镜像仓库注册地址。

ImageRegistryCredential.N.UserName String yourusername

镜像仓库用户名。

Container.N.ReadinessProbe.TimeoutSeconds Integer 1

检查超时的时间,默认为1秒,最小为1秒。

Container.N.ReadinessProbe.SuccessThreshold Integer 1

从上次检查失败后重新认定检查成功的检查次数阈值(必须是连续成功),默认为1。

Container.N.SecurityContext.Capability.Add.N RepeatList NET_ADMIN

枚举值,目前仅支持:NET_ADMIN。

Container.N.ReadinessProbe.TcpSocket.Port Integer 8000

TcpSocket检测的端口。

Container.N.ReadinessProbe.HttpGet.Scheme String HTTP

HTTP/HTTPS。

Container.N.LivenessProbe.PeriodSeconds Integer 5

检查执行的周期,默认为10秒,最小为1秒。

Container.N.SecurityContext.ReadOnlyRootFilesystem Boolean true

目前仅支持:true。

Container.N.EnvironmentVar.N.Key String PATH

变量名,长度 [1,128],取值范围:[0-9a-zA-Z]以及下划线 ‘_’,不能以数字开头。

Container.N.EnvironmentVar.N.Value String /usr/local/bin

变量值,长度[0,256],取值范围不限。

Container.N.EnvironmentVar.N.FieldRef.FieldPath String status.podIP

变量值引用,目前只支持”status.podIP”。

Container.N.LivenessProbe.TcpSocket.Port Integer 8000

TcpSocket检测的端口。

Container.N.Tty Boolean false

是否开启交互,默认为false,例如Command为 [“/bin/bash”] 时,需要设置为true。

Container.N.WorkingDir String /usr/local/

容器工作目录。

Container.N.Arg.N RepeatList 100

容器启动参数,上限10。

Container.N.Stdin Boolean false

此容器是否应在容器运行时为标准输入分配缓冲区。如果未设置,则容器中标准输入的读取值将导致EOF。默认为false。

Container.N.LivenessProbe.InitialDelaySeconds Integer 5

检查开始执行的时间,以容器启动完成为起点计算。

Container.N.VolumeMount.N.MountPropagation String None

数据卷的挂载传播设置。挂载传播允许将Container挂载的卷共享到同一Pod中的其他Container,甚至可以共享到同一节点上的其他Pod。取值范围:

  • None:该卷不感知任何后续在此卷或其子目录上执行的挂载操作。
  • HostToCotainer:该卷将会感知到后续在此卷或其子目录上的挂载操作。
  • Bidirectional:和HostToCotainer类似,能感知挂载操作。另外,该卷将被传播回主机和使用同一卷的所有Pod的所有容器。

默认值:None

Container.N.VolumeMount.N.MountPath String /pod/data

容器挂载数据卷的目录,容器挂载目录下的内容被Volume的内容直接覆盖,所以要慎用。

Container.N.VolumeMount.N.ReadOnly Boolean false

数据卷只读权限,默认值为 False。

Container.N.VolumeMount.N.SubPath String data2/

数据卷子路径。

Container.N.VolumeMount.N.Name String default-volume1

数据卷名称,同 Volume 中的 Name。

Container.N.ImagePullPolicy String Always

容器的镜像拉取策略。

Container.N.StdinOnce Boolean false

当标准输入为 true 时,标准输入流将在多个附加会话中保持开启状态。如果StdinOnce设为 true,标准输入在容器开启时被打开,在首个客户端附加到标准输入之前都为空,然后会一直保持开启状态,接收数据,直到客户端连接断开,此时标准输入被关闭,在容器重启前一直保持关闭状态。

Container.N.ReadinessProbe.PeriodSeconds Integer 3

检查执行的周期,默认为10秒,最小为1秒。

Container.N.LivenessProbe.SuccessThreshold Integer 1

从上次检查失败后重新认定检查成功的检查次数阈值(必须是连续成功),默认为1。当前必须为1。

Container.N.Command.N RepeatList sleep

容器启动命令,上限20,单个String,256个字符。

Container.N.ReadinessProbe.HttpGet.Path String /healthz

HttpGet检测的路径。

Container.N.LivenessProbe.Exec.Command.N RepeatList cat /tmp/healthy

容器内检测的命令。

Container.N.Port.N.Protocol String TCP

TCP/UDP。

Container.N.Port.N.Port Integer 80

端口号 1-65535。

Container.N.LivenessProbe.HttpGet.Scheme String HTTP

HTTP/HTTPS。

Container.N.ReadinessProbe.HttpGet.Port Integer 8080

HttpGet检测的端口号。

Container.N.Gpu Integer 1

图形化处理器。

Container.N.ReadinessProbe.InitialDelaySeconds Integer 3

检查开始执行的时间,以容器启动完成为起点计算。

Container.N.Memory Float 0.5

容器内存大小。

Container.N.LivenessProbe.FailureThreshold Integer 3

从上次检查成功后认定检查失败的检查次数阈值(必须是连续失败),默认为3。

Container.N.ReadinessProbe.Exec.Command.N RepeatList cat /tmp/healthy

容器内检测的命令。

Container.N.ReadinessProbe.FailureThreshold Integer 3

从上次检查成功后认定检查失败的检查次数阈值(必须是连续失败),默认为3。

Container.N.Cpu Float 0.25

容器CPU核数。

Container.N.LivenessProbe.HttpGet.Port Integer 8888

HttpGet检测的端口号。

Container.N.LivenessProbe.HttpGet.Path String /healthyz

HttpGet检测的路径。

Container.N.LivenessProbe.TimeoutSeconds Integer 1

检查超时的时间,默认为1秒,最小为1秒。

Container.N.SecurityContext.RunAsUser Long 1000

容器以用户ID 1000运行。

Volume.N.Type String ConfigFileVolume

数据卷类型。

Volume.N.DiskVolume.DiskSize Integer 15

DiskVolume的大小 GiB。

Volume.N.NFSVolume.Path String /share

NFS 数据卷路径。

Volume.N.DiskVolume.FsType String xfs

DiskVolume的系统类型。

Volume.N.FlexVolume.FsType String ext4

挂载的文件系统类型,默认取决于FlexVolume的script。

Volume.N.ConfigFileVolume.DefaultMode Integer 0644

ConfigFileVolume默认的权限。

Volume.N.NFSVolume.ReadOnly Boolean false

默认值为 false。

Volume.N.ConfigFileVolume.ConfigFileToPath.N.Path String liu/name

相对文件路径。

Volume.N.ConfigFileVolume.ConfigFileToPath.N.Mode Integer 0644

ConfigFileVolume目录权限。

Volume.N.ConfigFileVolume.ConfigFileToPath.N.Content String bGl1bWk=

配置文件内容 (32KB)。

Volume.N.FlexVolume.Options String {}

FlexVolume对象选项列表。为 KV形式,采用JSON传递。

Volume.N.FlexVolume.Driver String flexvolume

用于FlexVolume的驱动程序名称。

Volume.N.NFSVolume.Server String 3f9cd4a596-naw76.cn-shanghai.nas.aliyuncs.com

NFS 服务器地址。

Volume.N.DiskVolume.DiskId String d-xx

DiskVolume的ID。

Volume.N.Name String default-volume1

数据卷名称。

Volume.N.EmptyDirVolume.Medium String memory

EmptyDirVolume的存储媒介,默认为空,使用node文件系统;支持 memory,表示使用内存。

InitContainer.N.SecurityContext.Capability.Add.N RepeatList NET_ADMIN

枚举值,目前仅支持:NET_ADMIN。

InitContainer.N.Image String nginx

镜像。

InitContainer.N.VolumeMount.N.MountPropagation String None

数据卷的挂载传播设置。挂载传播允许将Container挂载的卷共享到同一Pod中的其他Container,甚至可以共享到同一节点上的其他Pod。取值范围:

  • None:该卷不感知任何后续在此卷或其子目录上执行的挂载操作。
  • HostToCotainer:该卷将会感知到后续在此卷或其子目录上的挂载操作。
  • Bidirectional:和HostToCotainer类似,能感知挂载操作。另外,该卷将被传播回主机和使用同一卷的所有Pod的所有容器。

默认值:None

InitContainer.N.VolumeMount.N.MountPath String /usr/share/

挂载目录,容器的挂载目录下的内容被volume的内容直接覆盖,所以要慎用。

InitContainer.N.VolumeMount.N.ReadOnly Boolean false

默认为false。

InitContainer.N.VolumeMount.N.SubPath String /usr/sub/

数据卷下的子目录,方便Pod将同一个Volume下不同目录挂载到容器不同目录。

InitContainer.N.VolumeMount.N.Name String test-empty

挂载数据卷的名称。

InitContainer.N.Port.N.Protocol String TCP

TCP/UDP。

InitContainer.N.Port.N.Port Integer 8888

端口号 1-65535。

InitContainer.N.SecurityContext.ReadOnlyRootFilesystem Boolean true

目前仅支持:true。

InitContainer.N.EnvironmentVar.N.Key String Path

变量名,长度[1,128],取值范围:[0-9a-zA-Z]以及下划线 ‘_’,不能以数字开头

InitContainer.N.EnvironmentVar.N.Value String /usr/bin/

变量值,长度【0,256】,取值范围不限。

InitContainer.N.EnvironmentVar.N.FieldRef.FieldPath String status.podIP

变量值引用,目前只支持”status.podIP”。

InitContainer.N.ImagePullPolicy String Always

镜像重启策略。

InitContainer.N.WorkingDir String /usr/local

工作目录。

InitContainer.N.Cpu Float 0.5

CPU大小。

InitContainer.N.Arg.N RepeatList 10

Init容器启动参数。

InitContainer.N.Command.N RepeatList sleep

Init容器启动指令。

InitContainer.N.Gpu Integer 1

图形化处理器。

InitContainer.N.SecurityContext.RunAsUser Long 587

以用户ID运行。

InitContainer.N.Memory Float 1.0

内存大小。

InitContainer.N.Name String test-init

Init容器名称。

DnsConfig.NameServer.N RepeatList 172.10.*.**

DNS 服务器 IP 地址列表。

DnsConfig.Search.N RepeatList svc.local.kubenetes

DNS 搜索域列表。

DnsConfig.Option.N.Value String value

对象的Value。

DnsConfig.Option.N.Name String name

对象的Name。

HostAliase.N.Ip String 1.1.1.1

添加IP。

HostAliase.N.Hostname.N RepeatList hehe.com

添加主机名。

SecurityContext.Sysctl.N.Value String 65536

实例运行的安全上下文的变量值。

SecurityContext.Sysctl.N.Name String kernel.msgmax

实例运行的安全上下文系统名称。

NtpServer.N RepeatList ntp.cloud.aliyuncs.com

Ntp服务器。

AcrRegistryInfo.N.Domain.N RepeatList *****-****-registry.cn-beijing.cr.aliyuncs.com

企业版访问凭证配置信息:域名,可选,默认为相应实例的所有域名。若要指定个别域名,多个以逗号分隔。

AcrRegistryInfo.N.InstanceName String acr-test

企业版访问凭证配置信息:实例名称。

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

企业版访问凭证配置信息:实例ID。企业版实例必须配置此项

AcrRegistryInfo.N.RegionId String cn-beijing

企业版访问凭证配置信息:所属地域。可选,默认为本地地域。

返回数据

名称 类型 示例值 描述
ContainerGroupId String eci-uf6fonnghi50u374****

实例ID,即容器组ID。

RequestId String 89945DD3-9072-47D0-A318-353284CFC7B3

请求ID,唯一标识。

示例

请求示例

https://eci.aliyuncs.com/?Action=CreateContainerGroup
&Container.1.Image=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest
&Container.1.1ame=nginx
&ContainerGroupName=nginx-test
&RegionId=cn-hangzhou
&SecurityGroupId=sg-uf66jeqopgqa9hdn****
&VSwitchId=vsw-uf6h3rbwbm90urjwa****
&<公共请求参数>

正常返回示例

XML格式

<CreateContainerGroupResponse>
      <RequestId>89945DD3-9072-47D0-A318-353284CFC7B3	</RequestId>
      <ContainerGroupId>eci-uf6fonnghi50u374****</ContainerGroupId>
</CreateContainerGroupResponse>

JSON格式

{
	"RequestId": "89945DD3-9072-47D0-A318-353284CFC7B3\t",
	"ContainerGroupId": "eci-uf6fonnghi50u374****"
}

错误码

HttpCode 错误码 错误信息 描述
400 Account.Arrearage Your account has an outstanding payment. 账号已经欠费。
400 DryRunOperation Request validation has been passed with DryRun flag set. 此次DryRun预检请求合格。
400 InvalidParameter.CPU.Memory The specified cpu and memory are not allowed cpu,mem不符合规格
400 InvalidParameter.DuplicatedName The container group include containers with duplicate names. 容器组内有重复名字的容器。
400 InvalidParameter.DuplicatedVolumeName The container group includes volumes with duplicate names. 容器组内有重复名字的数据卷。
400 IncorrectStatus %s 指定的实例状态不正确。
400 ServiceNotEnabled %s 该次请求所依赖的服务没有开通,请开通后再试。
400 ImageSnapshot.IncorrectStatus %s 用于镜像缓存的快照状态不正确。
400 ImageSnapshot.NotSupport %s 基于数据盘快照的镜像缓存功能暂未全网开放,如有需要请联系我们。
400 DiskVolume.NotSupport The disk volume is not supported. 云盘卷暂不支持,如有需要请联系我们。
400 RamRole.NotSupport The RAM role is not supported. ram实例角色不支持
400 DiskNumber.LimitExceed The maximum number of disks in an instance is exceeded. 实例下云盘数目超过限制。
400 InvalidPaymentMethod.InsufficientBalance No payment method is specified for your account. We recommend that you add a payment method or add funds to the prepayment balance. 您的账户暂无有效支付方式,请添加支付方式或保持预付款余额充足。
400 DiskVolume.NotInSameZone The instance to be created and the disk are not in the same zone. 即将创建的实例和云盘不在同一可用区。
400 NoPermission You are not authorized to use the "Product on ECI" feature. 您没有云产品on ECI的权限
400 HighCpuMemConfigRequired You need to apply to be added to the whitelist of the specified CPU and memory. 您需要申请CPU高配白名单
400 RecommendEmpty.InstanceTypeFamilyNotMatched The recommended instance type is unavailable in the current zone. Try again later. 当前可用区没有推荐的规格可使用,请稍后重试或者到其他的可用区创建。
400 LocalDiskAmountNotMatch The number of local volumes does not match the instance type. 本地盘数量跟实例规格不匹配
400 Payfor.CreditPayInsufficientBalance Your payment credit line is insufficient. 您的付款信用额度不足。
400 InvalidOperation.KMS.InstanceTypeNotSupport The specified instance is invalid. Only I/O optimized instances support KMS key. 指定的实例无效,只有 I/O 优化类型的实例支持设置“KMS Key”。
400 InvalidParameter.Encrypted.KmsNotEnabled KMS must be enabled for encrypted disks. 加密磁盘需要启用密钥管理服务。
400 InvalidParameter.KMS.EncryptedIllegal After configuring the parameter KmsKeyId, you must enable encryption. 设置参数“KmsKeyId”后,您必须开启加密属性。
403 OperationDenied.VswZoneMisMatch The specified VSwitchId is not in the specified Zone. 指定的交换机不在可用区
403 QuotaExceeded %s quota exceeded. 用户允许创建的实例已经超过限制
403 Zone.NotOnSale The specified zone is not available for purchase. 创建实例的可用区已经关闭售卖,请更换其他可用区。或者无法在该可用区使用指定 VPC 的虚拟交换机。
403 Forbidden.RiskControl This operation has been identified as an abnormal operation and cannot be processed. 此操作已被确定为一个操作异常,无法处理。
403 Forbidden.SubUser The specified action is not available for you. 当前用户无法执行该操作
403 Forbidden.OnlyForInvitedTest Eci create action is only open to invited users during public beta. Eci公测阶段只对受邀的用户开放。
403 OperationDenied.SecurityGroupMisMatch The specified VSwitchId and SecurityGroupId are not in the same VPC. 指定的交换机和安全组不在同一个VPC下
403 InvalidVSwitchId.IpNotEnough The specified VSwitch does not have enough IP addresses. 交换机没有足够ip地址
403 Forbidden.UserBussinessStatus This operation is not allowed, because you have overdue bills. Pay the overdue bill and try again. 用户处于欠费状态不允许创建,请充值后再尝试。
403 Forbidden.UserNotRealNameAuthentication This operation is not allowed, because you have not passed the real-name verification. 操作被禁止,因为用户还未进行实名认证。
403 InvalidUser.PassRoleForbidden The RAM user is not authorized to assume a RAM role. 子账号用户没有权限使用RAM实例角色
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.htm?userCode=wrvvs1rm&zuntopl 库存不足,请尝试其它系列或者其它可用区/地域的实例,推荐使用多可用区多规格配置来避免库存不足,更多信息见:https://help.aliyun.com/document_detail/157290.htm?userCode=wrvvs1rm&zuntopl
403 InvalidParameter.KMS.KeyId.Forbidden You are not authorized to access the specified KMSKeyId. 无权访问指定的 KMSKeyId。
403 NoPermission The RAM role AliyunECIContainerGroupRole does not belong to eci.aliyuncs.com. Please check and try again. RAM 角色 "AliyunECIContainerGroupRole" 不属于 "eci.aliyuncs.com",请检查后重试。
403 Forbidden.AccountClosed The operation is forbidden. Your account has been closed. 操作被禁止,因为用户账户已注销。
403 InvalidOperation.ResourceManagedByCloudProduct The operation is forbidden. The security group has been managed by another cloud product. 安全组由其他云产品管理,禁止操作。
403 Spot.NotMatched %s. We recommend that you use the create multi-zone function to avoid insufficient inventory. For more information, see https://help.aliyun.com/document_detail/157290.htm?userCode=wrvvs1rm&zuntopl %s. 推荐使用多可用区多规格配置来避免库存不足,更多信息见:https://help.aliyun.com/document_detail/157290.htm?userCode=wrvvs1rm&zuntopl
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. 我们检测到您的默认信用卡或借记卡存在安全风险。请通过电子邮件中的链接进行验证。
404 ImageSnapshot.NotFound The specified snapshot does not exist. 镜像缓存,快照不存在。
404 InvalidDiskId.NotFound The specified disk does not exist. 指定的云盘不存在。
404 InvalidParameter.KMS.KeyId.NotFound The specified KMSKeyId does not exist. 指定的参数“KMSKeyId”不存在。

访问错误中心查看更多错误码。