Creates 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 nginx

The name of the image.

ContainerGroupName String Yes nginx-test

The name of the container group.

RegionId String Yes cn-hangzhou

The region ID of the container group.

SecurityGroupId String Yes sg-uf66jeqopgqa9hdn****

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

VSwitchId String Yes vsw-uf6h3rbwbm90urjwa****

The ID of the VSwitch. Currently, container groups can only be deployed in Virtual Private Clouds (VPCs).

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 create a container group, plan the CIDR block of the VSwitch.

ZoneId String No cn-hangzhou-b

The ID of the zone where the container group is deployed. If you do not specify this parameter, the system assigns a zone ID for the container group. The default value is the zone ID assigned by the system.

RestartPolicy String No Always

The restart policy of the container group. Default value: 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 used to log on to the image repository.

ImageRegistryCredential.N.Password String No yourpaasword

The password 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: vCPUs.

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 of the container.

Container.N.ImagePullPolicy String No Always

The policy for pulling an image.

Container.N.Command.N RepeatList No sleep

The commands used to start the container. A maximum of 20 commands can be specified to start a container. Each command is a string and can be up to 256 characters in length.

Container.N.Arg.N RepeatList No 100

The startup parameters of the container. A maximum of 10 startup parameters can be specified to start a container.

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

The directory to which the volume is mounted. Data under this directory is overwritten by the data on the volume.

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

Specifies whether the volume is set to the read-only mode. Default value: 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 group.

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

The subdirectory of the volume.

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

The protocol of the container. Valid values: TCP and UDP.

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

The port number of the container. Valid values: 1 to 65535.

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

The name of the variable. The name can be1 to 128characters 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 256characters in length.

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

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

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

The scheme used for connecting to the host. Valid values: HTTP and HTTPS.

Container.N.ReadinessProbe.InitialDelaySeconds Integer No 3

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

Container.N.ReadinessProbe.PeriodSeconds Integer No 3

The interval for checking the container. Default value: 10. Minimum value: 1. Unit: seconds.

Container.N.ReadinessProbe.SuccessThreshold Integer No 1

After the last check failed, the minimum number of consecutive times that a check must be successful before the check is declared successful. Default value: 1.

Container.N.ReadinessProbe.FailureThreshold Integer No 3

After the last check succeeded, the minimum number of consecutive times that a check must fail before the check is declared failed. Default value: 3.

Container.N.ReadinessProbe.TimeoutSeconds Integer No 1

The timeout period of the check. Default value: 1. Minimum value: 1. Unit: seconds.

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

The commands used to check 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

The scheme used for connecting to the host. Valid values: HTTP and HTTPS.

Container.N.LivenessProbe.InitialDelaySeconds Integer No 5

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

Container.N.LivenessProbe.PeriodSeconds Integer No 5

The interval for checking the container. Default value: 10. Minimum value: 1. Unit: seconds.

Container.N.LivenessProbe.SuccessThreshold Integer No 1

After the last check failed, the minimum number of consecutive times that a check must be successful before the check is declared successful. Default value: 1. Currently, the value must be 1.

Container.N.LivenessProbe.FailureThreshold Integer No 3

After the last check succeeded, the minimum number of consecutive times that a check must fail before the check is declared failed. Default value: 3.

Container.N.LivenessProbe.TimeoutSeconds Integer No 1

The timeout period of the check. Default value: 1. Minimum value: 1. Unit: seconds.

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

The commands used to check the container.

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

The capability that you can add. Currently, the only valid value is NET_ADMIN.

Container.N.SecurityContext.ReadOnlyRootFilesystem Boolean No true

Specifies whether the root file system is set to the read-only mode. Default value: true.

Container.N.SecurityContext.RunAsUser Long No 1000

The user ID with which the container runs processes.

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

The port for the TCP socket method.

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

The port for the TCP socket method.

Container.N.Stdin Boolean No false

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

Specifies whether standard input streams are disconnected after a client is disconnected. If Container.N.Stdin is set to true, standard input streams remain connected among multiple sessions. If Container.N.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 value: false. For example, if the command is "/bin/bash", this parameter is set to true.

Container.N.Gpu Integer No 1

The amount of graphics processing unit (GPU) resources allocated to the container.

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 Network File System (NFS) server.

Volume.N.NFSVolume.Path String No /share

The path to the nfs volume.

Volume.N.NFSVolume.ReadOnly Boolean No false

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

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

The content of the configuration file. The maximum size of the file can be 32 KB.

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

The relative path to the configuration file.

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

The permissions on the ConfigFile volume.

Volume.N.Type String No ConfigFileVolume

The type of the volume.

Volume.N.EmptyDirVolume.Medium String No memory

The storage medium of the emptyDir volume. If you do not specify a storage medium for the emptyDir volume, it stores data in the file system of a node by default. A value of Memory indicates that the emptyDir volume stores data in the memory.

Volume.N.ConfigFileVolume.DefaultMode Integer No 0644

The default permissions on the ConfigFile volume.

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

The ID of the disk as a volume.

Volume.N.DiskVolume.FsType String No xfs

The file system type of the disk as a volume.

Volume.N.DiskVolume.DiskSize Integer No 15

The storage size of the disk as a volume. 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 FlexVolume objects. Each object is a key-value pair contained in a JSON string.

EipInstanceId String No eip-uf66jeqopgqa9hdn****

The instance ID of the Elastic IP Address (EIP).

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 used to start the container.

InitContainer.N.Arg.N RepeatList No 10

The startup parameters of the container.

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

The directory to which the volume is mounted. Data under this directory is overwritten by the data on the volume.

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

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

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

The name of the volume.

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

The subdirectory of the 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

The protocol of the container. Valid values: TCP and UDP.

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

The port number of the container. Valid values: 1 to 65535.

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

The name of the variable. The name can be1 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, the only valid value is status.podIP.

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

The capability that you can add. Currently, the only valid value is NET_ADMIN.

InitContainer.N.SecurityContext.ReadOnlyRootFilesystem Boolean No true

Specifies whether the root file system is set to the read-only mode. Default value: true.

InitContainer.N.SecurityContext.RunAsUser Long No 587

The user ID with which the container runs processes.

InitContainer.N.Gpu Integer No 1

The amount of GPU resources allocated to the container.

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

The IP addresses of Domain Name System (DNS) servers.

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

The DNS search 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-uf66jeqopgqa9hdn****

The ID of the resource group.

DnsPolicy String No uuid

The DNS policy set for the container group.

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

The client token that is used to guarantee 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 idempotence.

HostAliase.N.Ip String No 1.1.1.1

The IP address of the host.

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

The hostname of the container group.

InstanceType String No ecs.c5.xlarge

The instance type of the container group.

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

The name of the security context 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-2zebxkiifuyzzlhl****

The ID of the image cache snapshot.

RamRoleName String No RamTestRole

The Resource Access Management (RAM) role that the container group assumes. ECI and ECS share the same RAM role. For more information, see Use the instance RAM role by calling APIs.

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

The Network Time Protocol (NTP) server of the container group.

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 maximum period for restarting the container group. Unit: seconds.

SpotStrategy String No SpotPriceLimit

The preemption policy for the preemptible instance.

Default value: NoSpot. Valid values:

NoSpot: the regular pay-as-you-go instance.

SpotWithPriceLimit: the preemptible instance with a user-defined upper price limit.

SpotAsPriceGo: the preemptible instance whose price is based on the current market price.

SpotPriceLimit Float No 0.025

The maximum hourly price of the instance. This parameter is valid only when SpotStrategy is set to SpotWithPriceLimit. A maximum of three decimal places can be specified.

Response parameters

Parameter Type Example Description
ContainerGroupId String eci-uf6fonnghi50u374****

The ID of the container group.

RequestId String 28B583A8-313D-4383-8EA9-B5A9F7E07817

The unique ID of the request.

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=nginx
&ContainerGroupName=nginx-test
&RegionId=cn-hangzhou
&SecurityGroupId=sg-uf66jeqopgqa9hdn****
&VSwitchId=vsw-uf6h3rbwbm90urjwa****
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

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.
400 InvalidParameter.DuplicatedName The container group include containers with duplicate names. The error message returned because the container group contains containers with duplicate 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 specified 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 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 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 the current user 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 volumes with duplicate 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.
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 service required to call the operation is not activated. Activate the service 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 disk does not exist.
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.
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.
400 NoPermission You are not authorized to use the "Product on ECI" feature. The error message returned because you are not authorized to use Alibaba Cloud services with ECI.
400 HighCpuMemConfigRequired You need to apply to be added to the whitelist of the specified CPU and memory. The error message returned because your account is not authorized to use the specified CPU and memory resources.

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