Runs commands in a container.

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 Yes ExecContainerCommand

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

RegionId String Yes cn-hangzhou

The ID of the region where an elastic container instance is created.

ContainerGroupId String Yes eci-2zebxkiifulhl****

The ID of the elastic container instance.

ContainerName String Yes nginx

The name of the container.

Command String Yes ["/bin/sh", "-c", "ls -a"]

The commands to run in the container. You can specify up to 20 commands. Each command can be up to 256 characters in length.

The strings must be in the JSON format. Example: ["/bin/sh", "-c", "ls -a"].

TTY Boolean No false

Specifies whether to enable interaction. Default value: false.

If the command is a /bin/bash command, set the value to true.

Stdin Boolean No true

Specifies whether to read the commands from standard input (stdin). Default value: true.

Sync Boolean No false

Specifies whether to run the command immediately and return the result. Default value: false.

If you set this parameter to true, set the value of TTY to false.

Response parameters

Parameter Type Example Description
HttpUrl String https://eci.console.aliyun.com/terminal?param=X32a****

The HTTP URL. You can use this URL to enter the container within 30 seconds after this operation is called. For more information, see Use and integrate the Elastic Container Instance terminal.

RequestId String 28B583A8-313D-4383-7817-B5A9F7E0****

The unique ID of the request.

SyncResponse String Hello

The output of the command. This parameter is returned when Sync is set to true.

WebSocketUri String wss://eci-cn-shanghai.aliyun.com/exec/?s=ktHPx****

The WebSocket URL. You can use this URL to establish a WebSocket connection with the container.

Examples

Sample requests

https://eci.aliyuncs.com/?Action=ExecContainerCommand
&RegionId=cn-hangzhou
&ContainerGroupId=eci-2zebxkiifulhl****
&ContainerName=nginx
&Command=ls
&<Common request parameters>

Sample success responses

XML format

<ExecContainerCommandResponse>
      <RequestId>28B583A8-313D-4383-7817-B5A9F7E0****</RequestId>
      <WebSocketUri>wss://eci-cn-shanghai.aliyun.com/exec/?s=ktHPx****</WebSocketUri>
      <HttpUrl>https://eci.console.aliyun.com/terminal?param=X32a****</HttpUrl>
</ExecContainerCommandResponse>

JSON format

{
	"RequestId": "28B583A8-313D-4383-7817-B5A9F7E0****",
	"WebSocketUri": "wss://eci-cn-shanghai.aliyun.com/exec/?s=ktHPx****",
	"HttpUrl": "https://eci.console.aliyun.com/terminal?param=X32a****"
}

Error codes

HttpCode Error code Error message Description
400 InvalidParameter.ValueExceeded %s The error message returned because a specified parameter is invalid.
400 IncorrectStatus %s The error message returned because the status of the specified elastic container instance is invalid.

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