You can call this operation to create a container group.

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 CreateContainerGroup

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

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

The image of the container.

Container.N.Name String Yes nigix

The name of the container.

ContainerGroupName String Yes nigix-test

The name of the container group.

RegionId String Yes cn-hangzhou

The ID of the region where you want to deploy the container group.

SecurityGroupId String Yes sg-uf66jeqopgqa9hdn2atd

The ID of the security group to which the container group belongs. Container groups within the same security group can access each other.

VSwitchId String Yes vsw-uf6h3rbwbm90urjwavskd

The ID of the VSwitch. Currently, container groups can only be deployed in VPC networks.

The number of IP addresses in the VSwitch CIDR block determines the maximum number of container groups that can be created in the VSwitch. Before you can create an ECI instance, plan the CIDR block of the VSwitch.

ZoneId String No cn-hangzhou-b

The ID of the zone where you want to deploy the container group. If no value is specified, the system assigns a zone to the container group. By default, no value is specified.

RestartPolicy String No Always

The restart policy of the container group. Default is Always.

Tag.N.Key String No version

The key of the tag.

Tag.N.Value String No 3

The value of the tag.

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

The address of the image repository.

ImageRegistryCredential.N.UserName String No yourusername

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

ImageRegistryCredential.N.Password String No yourpaasword

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

Container.N.Cpu Float No 0.25

The amount of CPU resources allocated to the container. Unit: cores.

Container.N.Memory Float No 0.5

The amount of memory resources allocated to the container. Unit: GiB.

Container.N.WorkingDir String No /usr/local/

The working directory for the container.

Container.N.ImagePullPolicy String No Always

The policy for pulling an image.

Container.N.Command.N RepeatList No sleep

The commands run by the container. You can define a maximum of 20 commands. Minimum length per string: 256 characters

Container.N.Arg.N RepeatList No 100

The arguments passed to the commands. Maximum: 10.

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

The directory of the mounted volume. Data under this directory will be overwritten by the data in the volume.

Container.N.VolumeMount.N.ReadOnly Boolean No false

Specifies whether the volume is set to the read-only mode. Default is false.

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

The name of the volume. The name is the same as the volume you selected when you purchased the container.

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

The subdirectory of the volume.

Container.N.Port.N.Protocol String No TCP

Valid values: TCP and UDP.

Container.N.Port.N.Port Integer No 80

The port number. Valid values: 1 to 65535.

Container.N.EnvironmentVar.N.Key String No PATH

The name of the variable. The name can be 1 to 128 characters in length and can contain letters, digits, and underscores (_). It cannot start with a digit.

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

The value of the variable. The value can be 0 to 256 characters in length.

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

The source of the variable value. Currently, only status.podIP is supported.

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

The path to the HTTP GET method.

Container.N.ReadinessProbe.HttpGet.Port Integer No 8080

The port for the HTTP GET method.

Container.N.ReadinessProbe.HttpGet.Scheme String No HTTP

Valid values: HTTP and HTTPS.

Container.N.ReadinessProbe.InitialDelaySeconds Integer No 3

The time when the detection starts. The initial time is when the container is started.

Container.N.ReadinessProbe.PeriodSeconds Integer No 3

The detection interval in seconds. Default is 10, and minimum is 1.

Container.N.ReadinessProbe.SuccessThreshold Integer No 1

After the last detection failed, the minimum number of times that a detection must be successful consecutively before the detection is declared successful. Default is 1.

Container.N.ReadinessProbe.FailureThreshold Integer No 3

After the last detection succeeded, the minimum number of times that a detection must fail consecutively before the detection is declared failed. Default is 3.

Container.N.ReadinessProbe.TimeoutSeconds Integer No 1

The detection timeout period in seconds. Default is 1, and minimum is 1.

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

The command to run detection tasks in the container.

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

The path to the HTTP GET method.

Container.N.LivenessProbe.HttpGet.Port Integer No 8888

The port for the HTTP GET method.

Container.N.LivenessProbe.HttpGet.Scheme String No HTTP

Valid values: HTTP and HTTPS.

Container.N.LivenessProbe.InitialDelaySeconds Integer No 5

The time when the detection starts. The initial time is when the container is started.

Container.N.LivenessProbe.PeriodSeconds Integer No 5

The detection interval in seconds. Default is 10, and minimum is 1.

Container.N.LivenessProbe.SuccessThreshold Integer No 2

After the last detection failed, the minimum number of times that a detection must be successful consecutively before the detection is declared successful. Default is 1. Currently, the value must be set to 1.

Container.N.LivenessProbe.FailureThreshold Integer No 3

After the last detection succeeded, the minimum number of times that a detection must fail consecutively before the detection is declared failed. Default is 3.

Container.N.LivenessProbe.TimeoutSeconds Integer No 1

The detection timeout period in seconds. Default is 1, and minimum is 1.

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

The command to run detection tasks in the container.

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

Currently, the only valid value is NET_ADMIN.

Container.N.SecurityContext.ReadOnlyRootFilesystem Boolean No true

Currently, the only valid value is true.

Container.N.SecurityContext.RunAsUser Long No 1000

The container runs with the user ID 1000.

Container.N.ReadinessProbe.TcpSocket.Port Integer No 8000

The port used to test TCP sockets.

Container.N.LivenessProbe.TcpSocket.Port Integer No 8000

The port used to test TCP sockets.

Container.N.Stdin Boolean No true

Specifies whether the container allocates buffer resources to standard input streams while the container is running. If no value is specified, an end of file (EoF) error may occur. Default value: false.

Container.N.StdinOnce Boolean No false

If Stdin is set to true, standard input streams remain connected among multiple sessions. If StdinOnce is set to true, standard input streams are connected after the container is started, and remain idle until a client is connected to receive data. After the client is disconnected, streams are also disconnected, and remain disconnected until the container is started again.

Container.N.Tty Boolean No false

Specifies whether interaction is enabled. Default is false. For example, if the command is "/bin/bash", this parameter is set to true.

Container.N.Gpu Integer No 1

The number of GPUs.

Volume.N.Name String No default-volume1

The name of the volume.

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

The address of the NFS server.

Volume.N.NFSVolume.Path String No /share

The path to the NFS volume.

Volume.N.NFSVolume.ReadOnly Boolean No false

Default value: false.

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

The content of the configuration file. Maximum size: 32 KB.

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

The relative file path.

Volume.N.Type String No ConfigFileVolume

The type of the volume.

Volume.N.EmptyDirVolume.Medium String No memory

The storage medium of EmptyDirVolume. By default, no value is specified, which indicates that EmptyDirVolume uses the node file system as storage. You can also set the value to Memory to use the memory as storage.

Volume.N.DiskVolume.DiskId String No d-xx

The ID of DiskVolume.

Volume.N.DiskVolume.FsType String No xfs

The system type of DiskVolume.

Volume.N.DiskVolume.DiskSize Integer No 15

The size of DiskVolume. Unit: GiB.

Volume.N.FlexVolume.Driver String No flexvolume

The name of the FlexVolume driver.

Volume.N.FlexVolume.FsType String No ext4

The type of the mounted file system. The default value is determined by the script of FlexVolume.

Volume.N.FlexVolume.Options String No {}

The list of FlexVolume objects. Each object is a key-value pair contained in a JSON string.

EipInstanceId String No eip-xxx

The ID of the elastic IP address.

InitContainer.N.Name String No test-init

The name of the init container.

InitContainer.N.Image String No nginx

The image of the container.

InitContainer.N.Cpu Float No 0.5

The amount of CPU resources allocated to the container.

InitContainer.N.Memory Float No 1.0

The amount of memory resources allocated to the container.

InitContainer.N.WorkingDir String No /usr/local

The working directory of the container.

InitContainer.N.ImagePullPolicy String No Always

The restart policy of the image.

InitContainer.N.Command.N RepeatList No sleep

The commands run by the init container.

InitContainer.N.Arg.N RepeatList No 10

The arguments passed to the commands.

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

The directory of the mounted volume. Data under this directory will be overwritten by the data in the volume.

InitContainer.N.VolumeMount.N.ReadOnly Boolean No false

Default value: false.

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

The name of the mounted volume.

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

The subdirectory of the mounted volume. The container group can mount different directories of the same volume to different subdirectories of containers.

InitContainer.N.Port.N.Protocol String No TCP

Valid values: TCP and UDP.

InitContainer.N.Port.N.Port Integer No 8888

The port number. Valid values: 1 to 65535.

InitContainer.N.EnvironmentVar.N.Key String No Path

The name of the variable. The name can be 1 to 128 characters in length and can contain letters, digits, and underscores (_). It cannot start with a digit.

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

The value of the variable. The value can be 0 to 256 characters in length.

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

The source of the variable value. Currently, only status.podIP is supported.

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

Currently, the only valid value is NET_ADMIN.

InitContainer.N.SecurityContext.ReadOnlyRootFilesystem Boolean No false

Currently, the only valid value is true.

InitContainer.N.SecurityContext.RunAsUser Long No 587

The user ID with which the container runs.

InitContainer.N.Gpu Integer No 1

The number GPUs.

DnsConfig.NameServer.N RepeatList No x.x.x.x

The list of DNS server IP addresses.

DnsConfig.Search.N RepeatList No svc.local.kubenetes

The list of DNS lookup domains.

DnsConfig.Option.N.Name String No name

The name of the object.

DnsConfig.Option.N.Value String No value

The value of the object.

Cpu Float No 1.0

The amount of CPU resources allocated to the container group.

Memory Float No 2.0

The amount of memory resources allocated to the container group.

ResourceGroupId String No rg-xxx

The ID of the resource group.

DnsPolicy String No uuid

The DNS policy.

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

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 t10046.dita#reference_zdl_bmg_ydb.

HostAliase.N.Ip String No 1.1.1.1

Adds an IP address.

HostAliase.N.Hostname.N RepeatList No hehe.com

Adds a host name.

InstanceType String No ecs.c5.xlarge

The type of the ECS instance.

SecurityContext.Sysctl.N.Name String No kernel.msgmax

The name of the security context system that the container group runs.

SecurityContext.Sysctl.N.Value String No 65536

The variable value of the security context that the container group runs.

SlsEnable Boolean No false

Specifies whether to enable logging. Default value: False.

ImageSnapshotId String No imc-2zebxkiifuyzzlhl199h

The ID of the image cache.

RamRoleName String No test-xxx

The RAM role that the container group assumes. ECI and ECS share the same RAM role. For more information, see t9666.dita#concept_jwk_pd5_xdb.

NtpServer.N RepeatList No ntp.cloud.aliyuncs.com

The NTP server.

TerminationGracePeriodSeconds Long No 60

The buffer time for the program to handle operations before it is stopped.

AutoMatchImageCache Boolean No false

Specifies whether to automatically match the image cache.

Ipv6AddressCount Integer No 128

The number of IPv6 addresses.

ActiveDeadlineSeconds Long No 1000

The validity period in seconds.

Response parameters

Parameter Type Example Description
RequestId String 28B583A8-313D-4383-8EA9-B5A9F7E07817

The unique ID of the request.

ContainerGroupId String eci-uf6fonnghi50u374a0i4

The ID of the container group.

Examples

Sample requests

http(s)://eci.aliyuncs.com/? Action=CreateContainerGroup
&Container.1.Image=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest
&Container.1.1ame=nigix
&ContainerGroupName=nigix-test
&RegionId=cn-hangzhou
&SecurityGroupId=sg-uf66jeqopgqa9hdn2atd
&VSwitchId=vsw-uf6h3rbwbm90urjwavskd
&<Common request parameters>

Sample success responses

XML format

<ContainerGroupId>eci-uf6fonnghi50u374a0i4</ContainerGroupId>
<RequestId>28B583A8-313D-4383-8EA9-B5A9F7E07817</RequestId>

JSON format

{  
   "ContainerGroupId":"eci-uf6fonnghi50u374a0i4",
   "RequestId":"28B583A8-313D-4383-8EA9-B5A9F7E07817"
}

Examples of request parameters


ImageRegistryCredential.N.Server=registry-vpc.cn-shanghai.aliyuncs.com
ImageRegistryCredential.N.UserName=yourusername
ImageRegistryCredential.N.Password=yourpaasword

Volume.N.Name=default-volume1
Volume.N.Type=ConfigFileVolume
Volume.N.ConfigFileVolume.ConfigFileToPath.1.Content=bGl1bWk=
Volume.N.ConfigFileVolume.ConfigFileToPath.1.Path=liu/name
Volume.N.ConfigFileVolume.ConfigFileToPath.2.Content=YWxpeXVu
Volume.N.ConfigFileVolume.ConfigFileToPath.2.Path=liu/com

Volume.N.Name=default-volume1
Volume.N.Type=NFSVolume
Volume.N.NFSVolume.Path=/share
Volume.N.NFSVolume.Server=3f9cd4a596-naw76.cn-shanghai.nas.aliyuncs.com
Volume.N.NFSVolume.ReadOnly=False

Volume.N.Name: default-volume
Volume.N.Type: EmptyDirVolume

Volume.N.Name=my-static-diskvolume
Volume.N.Type=DiskVolume
Volume.N.DiskVolume.FsType=ext4
Volume.N.DiskVolume.DiskId=d-2ze4rk800li49moq****
Note DiskIdThe ID of the cloud disk that you have created. The disk must be deployed in the same zone where the container group is deployed. All cloud disk types are supported. For more information, see t9558.dita#concept_n1s_rzb_wdb.
Note If the cloud disk is not formatted, the system automatically formats the disk to a type specified by FsType. Currently, only Ext3, Ext4, and XFS are supported.

Volume.N.Name=my-dynamic-diskvolume
Volume.N.Type=DiskVolume
Volume.N.DiskVolume.FsType=ext4
Volume.N.DiskVolume.DiskSize=20
Note DiskSizeSpecifies the size of cloud disks to be dynamically created. Valid disk sizes are from 20 to 500 GiB.
Note If DiskId does not have a value, DiskSize is required. If both the two fields have a value, DiskSize will be ignored.

Notes:

1. After all the target volumes have been mounted to the container directories, the existing data under the directories will be overwritten. EmptyDirVolume will directly deletes all existing data. Proceed with caution.

2. Each cloud disk can be mounted to one container group only. You can only mount one cloud disk to each container group, except ImgeCache disks that are used to generate snapshots.

3. Cloud disks that are dynamically created are created and deleted along with the container group.


Tag.N1.Key=version
Tag.N1.Value=v3
Tag.N2.Key=app
Tag.N2.Value=nginx

DnsConfig.NameServer.N=x.x.x.x
DnsConfig.Search.N=svc.local.kubenetes
DnsConfig.Option.N.Name=name
DnsConfig.Option.N.Value=vale

HostAliase.N.Hostname.1=hehe.com
HostAliase.N.Hostname.2=haha.com
HostAliase.N.Ip=42.101.1.10

SecurityContext.Sysctl.1.Name=kernel.shm_rmid_forced,
SecurityContext.Sysctl.1.Value='0',
SecurityContext.Sysctl.2.Name=kernel.msgmax,
SecurityContext.Sysctl.2.Value='65536',

#base params
Container.1.Image=registry.cn-hangzhou.aliyuncs.com/eci_open/nginx:latest
Container.1.Name=nginx-liu
Container.1.Cpu=1
Container.1.Memory=2
Container.1.ImagePullPolicy=Always
Container.1.WorkingDir=/usr/local/share/nginx
#commands and args
Container.1.Command.1=bash
Container.1.Arg.1=-c
Container.1.Arg.2= date; sleep 100
#EnvironmentVar
Container.1.EnvironmentVar.1.Key=PATH
Container.1.EnvironmentVar.1.Value=/usr/local/bin
Container.1.EnvironmentVar.2.Key=ECI_IP
Container.1.EnvironmentVar.2.FieldRef.FieldPath=status.podIP
#stdin
Container.1.Stdin=True
Container.1.StdinOnce=False
Container.1.Tty=True
#port
Container.1.Port.1.Protocol=TCP
Container.1.Port.1.Port=80
#VolumeMounts
Container.1.VolumeMount.1.Name=default-volume1
Container.1.VolumeMount.1.MountPath=/pod/data
Container.1.VolumeMount.1.ReadOnly=False
Container.1.VolumeMount.2.Name=default-volume2
Container.1.VolumeMount.2.SubPath=data2/
Container.1.VolumeMount.2.MountPath=/pod/data2/
Container.1.VolumeMount.2.ReadOnly=False
#ReadinessProbe
Container.1.ReadinessProbe.TcpSocket.Port=80
Container.1.ReadinessProbe.InitialDelaySeconds=10
Container.1.ReadinessProbe.PeriodSeconds=10
Container.1.ReadinessProbe.FailureThreshold=3
Container.1.ReadinessProbe.SuccessThreshold=3
Container.1.ReadinessProbe.TimeoutSeconds=5
#LivenessProbe
Container.1.LivenessProbe.Exec.Command.1=/bin/sh
Container.1.LivenessProbe.Exec.Command.2=cat
Container.1.LivenessProbe.Exec.Command.3=/etc/nginx/nginx.conf
Container.1.LivenessProbe.InitialDelaySeconds=10
Container.1.LivenessProbe.PeriodSeconds=10
Container.1.LivenessProbe.FailureThreshold=3
Container.1.LivenessProbe.SuccessThreshold=1
Container.1.LivenessProbe.TimeoutSeconds=5
#SecurityContext
Container.1.SecurityContext.Capability.Add.1=NET_ADMIN
Container.1.SecurityContext.ReadOnlyRootFilesystem=True
Container.1.SecurityContext.RunAsUse=1337
#ntpServer
NtpServer.1=ntp.cloud.aliyuncs.com
NtpServer.2=ntp7.cloud.aliyuncs.com

Error code

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.
400 InvalidParameter.DuplicatedName The container group include containers with duplicate names. The error message returned because the container group contains duplicate container names.
403 OperationDenied.NoStock Sales of this resource are temporarily suspended in the specified region; please try again later. The error message returned because the specified resource is insufficient. Specify another resource, region, or zone.
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 zone.
403 QuotaExceeded %s quota exceeded. The error message returned because the number of container groups that you have created has reached the upper limit.
403 Zone.NotOnSale The specified zone is not available for purchase. The error message returned because the specified zone is unavailable. Specify another zone. Or the VSwitch of the specified VPC instance is unavailable in the zone.
403 Forbidden.RiskControl This operation has been identified as an abnormal operation and cannot be processed. The error message returned because the specified operation has been 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 cannot perform the specified operation.
403 Forbidden.OnlyForInvitedTest Eci create action is only open to invited users during public beta. The error message returned because ECI is only available to invited users during the public preview period.
400 InvalidParameter.DuplicatedVolumeName The container group includes volumes with duplicate names. The error message returned because the container group contains duplicate volume names.
400 IncorrectStatus %s The error message returned because the status of the specified container group 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 network.
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 overdue payments. Settle the overdue payments 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 resource required to call the request is not activated. Activate the resource and try again later.
404 ImageSnapshot.NotFound The specified snapshot does not exist. The error message returned because no image cache or snapshot exists.
400 ImageSnapshot.IncorrectStatus %s The error message returned because the status of the image cache snapshot is invalid.
400 ImageSnapshot.NotSupport %s The error message returned because the image cache feature based on disk snapshots is not available to all users. If you need to use this feature, contact Alibaba Cloud customer service.
404 InvalidDiskId.NotFound The specified disk does not exist. The error message returned because the specified cloud disk does not exist.
400 DiskVolume.NotSupport The disk volume is not supported. The error message returned because the cloud 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.
403 NoPermission The RAM role does not belong to ECS. The error message returned because the RAM role does not belong to ECS.
400 DiskNumber.LimitExceed The maximum number of disks in an instance is exceeded. The error message returned because the number of disks attached to the container group has reached the upper limit.
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. The error message returned because your Alibaba Cloud account does not have a valid payment method. Specify a valid payment method or top up the balance.
400 DiskVolume.NotInSameZone The instance to be created and the disk are not in the same zone. The error message returned because the region of the container group that you want to create is not the same as that of the cloud disk.