You can call this operation to run 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 No ExecContainerCommand

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

RegionId String Yes cn-hangzhou

The region ID of the elastic container instance.

ContainerGroupId String Yes eci-2zebxkiifulhl****

The ID of the elastic container instance.

ContainerName String Yes nginx

The name of the container.

Command String Yes ls

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: ["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.

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 ID of the request.

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

The WebSocket URL. You can use this URL to establish a WebSocket connection to 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

HTTP status code 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.