Create an exec instance Run in API Explorer

POST /containers/{id}/exec

Run a command inside a running container.

Path parameters

  • id string Required

    ID or name of container

application/json

Body Required

Exec configuration

  • AttachStdin boolean

    Attach to stdin of the exec command.

  • AttachStdout boolean

    Attach to stdout of the exec command.

  • AttachStderr boolean

    Attach to stderr of the exec command.

  • ConsoleSize array[integer]

    Initial console size, as an [height, width] array.

    At least 2 but not more than 2 elements. Minimum value of each is 0.

  • DetachKeys string

    Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.

  • Tty boolean

    Allocate a pseudo-TTY.

  • Env array[string]

    A list of environment variables in the form ["VAR=value", ...].

  • Cmd array[string]

    Command to run, as a string or array of strings.

  • Privileged boolean

    Runs the exec process with extended privileges.

    Default value is false.

  • User string

    The user, and optionally, group to run the exec process inside the container. Format is one of: user, user:group, uid, or uid:gid.

  • WorkingDir string

    The working directory for the exec process inside the container.

Responses

  • 201 application/json

    no error

    Hide response attribute Show response attribute object
    • Id string Required

      The id of the newly created object.

  • 404 application/json

    no such container

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 409 application/json

    container is paused

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 500 application/json

    Server error

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

POST /containers/{id}/exec
curl \
 --request POST 'http://api.example.com/v1.44/containers/{id}/exec' \
 --header "Content-Type: application/json" \
 --data '{"Cmd":["date"],"Env":["FOO=bar","BAZ=quux"],"Tty":false,"DetachKeys":"ctrl-p,ctrl-q","AttachStdin":false,"AttachStderr":true,"AttachStdout":true}'
Request examples
{
  "Cmd": [
    "date"
  ],
  "Env": [
    "FOO=bar",
    "BAZ=quux"
  ],
  "Tty": false,
  "DetachKeys": "ctrl-p,ctrl-q",
  "AttachStdin": false,
  "AttachStderr": true,
  "AttachStdout": true
}
Response examples (201)
{
  "Id": "string"
}
Response examples (404)
{
  "message": "No such container: c2ada9df5af8"
}
Response examples (404)
{
  "message": "Something went wrong."
}
Response examples (409)
{
  "message": "Something went wrong."
}
Response examples (409)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}