All Products
Search
Document Center

CreateContainerGroup

Last Updated: May 16, 2019

You can call this operation to create a container group.

Request parameters

Name Type Required Description
Action String Yes The operation that you want to perform. Set the value to CreateContainerGroup.
RegionId String Yes The ID of the region in which the instance resides.
ZoneId String No The ID of the zone in which the instance resides. If you leave the parameter blank, the system assigns a zone for you. The default value is blank.
SecurityGroupId String Yes The ID of the security group to which the instance belongs. Instances in the same security group can access one another.
VSwitchId String Yes The ID of the specified VSwitch. Currently, ECI instances can only be deployed in VPCs.
ContainerGroupName String Yes The name of the container group.
ImageRegistryCredentials ImageRegistryCredential[] No The information for logging on to the container image registry.
Volumes Volume[] No The list of data volumes.
RestartPolicy String No The policy for restarting the instance. Default value: Always.
Containers Container[] Yes The containers that constitute the container group.
Tags Tag[] No The tag of the container.

Response parameters

Name Type Description
ContainerGroupId String The ID of the container group.

Examples

Sample requests

  1. http://eci.aliyuncs.com/?&Action=CreateContainerGroup
  2. &RegionId=cn-shanghai
  3. &SecurityGroupId=sg-uf66jeqopgqa9hdn2atd
  4. &VSwitchId=vsw-uf6h3rbwbm90urjwavskd
  5. &ContainerGroupName=1oo
  6. &Container.1.Command.1=%2Fbin%2Fsh
  7. &Container.1.Command.2=-c
  8. &Container.1.Command.3=echo+111111111111+11111111111111%3B+sleep+1000000000000000
  9. &Container.1.Cpu=1.00
  10. &Container.1.Image=ubuntu
  11. &Container.1.Memory=2.00
  12. &Container.1.Name=u1
  13. &<Common request parameters>

Sample responses

JSON format
  1. {
  2. "ContainerGroupId":"eci-uf6fonnghi50u374a0i4",
  3. "RequestId":"28B583A8-313D-4383-8EA9-B5A9F7E07817"
  4. }

Definitions

Name Description
ContainerGroup The container group.
Container The container.
ContainerState The status of the container.
Event The event of the container group.
ImageRegistryCredential The information for logging on to the container image registry.
Volume The data volume.
VolumeMount The volume mount point.
Tag The tag of the container.

ContainerGroup

Name Type Required Description
RegionId String Yes The ID of the region in which the instance resides.
ZoneId String No The ID of the zone in which the instance resides. If you leave the parameter blank, the system assigns a zone for you. The default value is blank.
SecurityGroupId String Yes The ID of the security group to which the instance belongs. Instances in the same security group can access one another.
VSwitchId String Yes The ID of the specified VSwitch. Currently, ECI instances can only be deployed in VPCs.
ContainerGroupName String Yes The name of the container group.
ContainerGroupID String No The ID of the container group.
ImageRegistryCredentials ImageRegistryCredential[] No The information for logging on to the container image registry. You can set a maximum of 10 sets of image registry logon information for each account.
Volumes Volume[] No The data volume. You can configure a maximum of 20 data volumes.
RestartPolicy String No The policy for restarting the container. Valid values: Always, OnFailure, and Never.
Containers Container[] Yes The list of containers. You can configure a maximum of five containers in a container group.
Events Event[] No The event details.
IntranetIP String No The internal network IP address.
Tags Tag[] No The instance tag in the format of a key/value pair. You can define a maximum of 20 tags for each instance.
Status String No The creation status of the container. Valid values: Pending, Running, Succeeded, Failed, Scheduling, and ScheduleFailed.
CreationTime String No The time at which the system receives the request for creating the container group. The time stamp must be in UTC and follow the RFC 3339 format. For example, 2018-08-02T15:00:00Z.
SucceededTime String No The time at which all containers in the same container group exit after executing specified tasks. The time stamp must be in UTC and follow the RFC 3339 format. For example, 2018-08-02T15:00:00Z.

Container

Name Type Required Description
Commands String[] No The commands run by the container. You can define a maximum of 20 commands. Minimum length per string: 256 characters.
Args String[] No The arguments passed to the commands. Maximum: 10.
EnvironmentVars EnvironmentVar[] No The environment variables in the operating system in which you operate the container. The environment variables are key/value pairs, and both the key and the value are strings. Maximum: 100. Key indicates the name of the environment variable. Value indicates the value of the environment variable.
Image String Yes The container image.
Name String Yes The name of the container.
Cpu Float Yes The central processing unit (CPU) assigned to the container.
Memory Float Yes The memory assigned to the container. Unit: GiB.
VolumeMounts VolumeMount[] No The number of data volumes that are mounted onto the container. Maximum: 16.
CurrentState ContainerState No The current status of the container.
PreviousState ContainerState No The previous status of the container.
RestartCount Integer No The number of restarts.
WorkingDir String No The working directory for the container.
Ports ContainerPort[] No The container ports or protocols to be exposed. You can expose a maximum of 100 container ports (protocols).

ContainerState

The following parameters are response parameters only.

Name Type Description
StartTime Timestamp The time at which the container starts running.
State String The status of the container. Valid values: Waiting, Running, and Terminated.
DetailStatus String The details for the container status.
FinishTime Timestamp The time at which the container stops running.
ExitCode Integer The exit code for the container.

Event

The following parameters are response parameters only.

Name Type Description
Count Integer The number of occurrences of the event.
FirstTimestamp String The time at which the event starts.
LastTimestamp String The time at which the event finishes.
Message String The event message.
Name String The name of the event.
Type String The type of the event. Valid values: Normal and Warning.

ImageRegistryCredential

Name Type Required Description
Server String Yes The URL for the image registry without http:// or https:// prefix.
UserName String Yes The username for the image registry.
Password String Yes The password for the image registry.

Volume

Name Type Required Description
Type String Yes The type of the data volume. Valid values: EmptyDirVolume, NFSVolume, and ConfigFileVolume.
Name String Yes The name of the data volume.
NFSVolume.Server String No The address for the NFS server.
NFSVolume.Path String No The path to the NFS volume.
NFSVolume.ReadOnly Boolean No Default value: False.
ConfigFileVolume.ConfigFileToPath ConfigFileToPath[] No The path to the configuration file.
EmptyDirVolume.Enable Boolean No Default value: False.

ConfigFileToPath

Name Type Required Description
Path String Yes The relative file path.
Content String No The content of the configuration file. Maximum size: 32 KB.
VolumeMount
Name Type Required Description
Name String Yes The name of the data volume.
MountPath String Yes The volume mount point.
ReadOnly Boolean Yes Default value: False.

Tag

Name Type Required Description
Key String Yes The keyword of the tag.
Value String No The value of the tag.

Error codes

Error codes specific to this API operation are as follows. For more information about the error codes that are common to all ECI API operations, see Common error codes.

Error code Error message HTTP status code Description
400 InvalidParameter The specified parameter {ParameterName} is not valid. The error message returned when the parameter value is invalid.
400 MissingParameter The input parameter {ParameterName} that is mandatory for processing this request is not supplied. The error message returned when a required parameter is not specified.
400 Account.Arrearage Your account has an outstanding payment. The error message returned when your account has an overdue bill.
400 [DO NOT TRANSLATE] [DO NOT TRANSLATE] [DO NOT TRANSLATE]
400 IncorrectStatus The current status of {Status} does not support this operation. The error message returned when this operation is not supported under the current instance status.
400 InvalidParameter.CPU.Memory The specified cpu and memory are not allowed The error message returned when the specified CPU and memory is invalid.
400 InvalidParameter.DuplicatedName Container names in container group can not be duplicated. The error message returned when the container name already exists in the container group.
400 InvalidParameter.DuplicatedVolumeName The container group includes volumes with duplicate names. The error message returned when there are duplicate data volume names.
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 beta release.
403 QuotaExceeded {Value} quota exceeded. The error message returned when the number of instances created exceeds the upper limit.
403 OperationDenied.VswZoneMisMatch The specified VSwitchId is not in the specified Zone. The error message returned when the VSwitch does not reside in the specified zone.
403 OperationDenied.NoStock Sales of this resource are temporarily suspended in the specified region; please try again later. The error message returned when the specified resource is out of stock. Please try other regions and zones.
403 OperationDenied.SecurityGroupMisMatch The specified VSwitchId and SecurityGroupId are not in the same VPC. The error message returned when the specified VSwitch and security group are not deployed in the same VPC.
403 Throttling.Vcpu.PerDay {Value} The error message returned when the number of requests sent exceeds the daily limit.
403 Zone.NotOnSale The specified zone is not available for purchase. The error message returned when the sales of instances in the specified zone is currently suspended. Please try other zones. Or the error message returned when the VSwitch in the specified VPC cannot be used in this zone.
503 ServiceUnavailable.RegionMaintaining System maintenance is in progress on the selected region, please wait a few minutes before trying again. The error message returned when system maintenance is in progress in the selected region. Please try again later.