Docker Exec API

Run new commands inside running containers. Refer to the [command-line reference](https://docs.docker.com/engine/reference/commandline/exec/) for more information. To exec a command in a container, you first need to create an exec instance, then start it. These two API endpoints are wrapped up in a single command-line command, `docker exec`.

Operations 4

POST /containers/{id}/exec Create an exec instance #
POST /exec/{id}/start Start an exec instance #
POST /exec/{id}/resize Resize an exec instance #
GET /exec/{id}/json Inspect an exec instance #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/docker-exec-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

docker-exec-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Docker Engine Exec API
  version: '1.54'
  x-logo:
    url: https://docs.docker.com/assets/images/logo-docker-main.png
  description: The Engine API is an HTTP API served by Docker Engine.
servers:
- url: /v1.54
tags:
- name: Exec
  x-displayName: Exec
  description: 'Run new commands inside running containers. Refer to the

    command-line reference

    for more information.


    To exec a command in a container, you first need to create an exec instance,

    then start it. These two API endpoints are wrapped up in a single command-line

    command, `docker exec`.'
paths:
  /containers/{id}/exec:
    post:
      summary: Create an exec instance
      description: Run a command inside a running container.
      operationId: ContainerExec
      responses:
        201:
          description: no error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IDResponse'
        404:
          description: no such container
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: 'No such container: c2ada9df5af8'
        409:
          description: container is paused
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        500:
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      parameters:
      - name: id
        in: path
        description: ID or name of container
        required: true
        schema:
          type: string
      tags:
      - Exec
      requestBody:
        content:
          application/json:
            schema:
              type: object
              title: ExecConfig
              properties:
                AttachStdin:
                  type: boolean
                  description: Attach to `stdin` of the exec command.
                AttachStdout:
                  type: boolean
                  description: Attach to `stdout` of the exec command.
                AttachStderr:
                  type: boolean
                  description: Attach to `stderr` of the exec command.
                ConsoleSize:
                  type:
                  - array
                  - 'null'
                  description: Initial console size, as an `[height, width]` array.
                  minItems: 2
                  maxItems: 2
                  items:
                    type: integer
                    minimum: 0
                  example:
                  - 80
                  - 64
                DetachKeys:
                  type: string
                  description: '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:
                  type: boolean
                  description: Allocate a pseudo-TTY.
                Env:
                  description: 'A list of environment variables in the form `["VAR=value", ...]`.

                    '
                  type: array
                  items:
                    type: string
                Cmd:
                  type: array
                  description: Command to run, as a string or array of strings.
                  items:
                    type: string
                Privileged:
                  type: boolean
                  description: Runs the exec process with extended privileges.
                  default: false
                User:
                  type: string
                  description: '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:
                  type: string
                  description: 'The working directory for the exec process inside the container.

                    '
              example:
                AttachStdin: false
                AttachStdout: true
                AttachStderr: true
                DetachKeys: ctrl-p,ctrl-q
                Tty: false
                Cmd:
                - date
                Env:
                - FOO=bar
                - BAZ=quux
        description: Exec configuration
        required: true
  /exec/{id}/start:
    post:
      summary: Start an exec instance
      description: 'Starts a previously set up exec instance. If detach is true, this endpoint

        returns immediately after starting the command. Otherwise, it sets up an

        interactive session with the command.'
      operationId: ExecStart
      responses:
        200:
          description: No error
        404:
          description: No such exec instance
          content:
            application/vnd.docker.raw-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            application/vnd.docker.multiplexed-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        409:
          description: Container is stopped or paused
          content:
            application/vnd.docker.raw-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            application/vnd.docker.multiplexed-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      parameters:
      - name: id
        in: path
        description: Exec instance ID
        required: true
        schema:
          type: string
      tags:
      - Exec
      requestBody:
        content:
          application/json:
            schema:
              type: object
              title: ExecStartConfig
              properties:
                Detach:
                  type: boolean
                  description: Detach from the command.
                  example: false
                Tty:
                  type: boolean
                  description: Allocate a pseudo-TTY.
                  example: true
                ConsoleSize:
                  type:
                  - array
                  - 'null'
                  description: Initial console size, as an `[height, width]` array.
                  minItems: 2
                  maxItems: 2
                  items:
                    type: integer
                    minimum: 0
                  example:
                  - 80
                  - 64
  /exec/{id}/resize:
    post:
      summary: Resize an exec instance
      description: 'Resize the TTY session used by an exec instance. This endpoint only works

        if `tty` was specified as part of creating and starting the exec instance.'
      operationId: ExecResize
      responses:
        200:
          description: No error
        400:
          description: bad parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/plain:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        404:
          description: No such exec instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/plain:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        500:
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/plain:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      parameters:
      - name: id
        in: path
        description: Exec instance ID
        required: true
        schema:
          type: string
      - name: h
        in: query
        required: true
        description: Height of the TTY session in characters
        schema:
          type: integer
      - name: w
        in: query
        required: true
        description: Width of the TTY session in characters
        schema:
          type: integer
      tags:
      - Exec
  /exec/{id}/json:
    get:
      summary: Inspect an exec instance
      description: Return low-level information about an exec instance.
      operationId: ExecInspect
      responses:
        200:
          description: No error
          content:
            application/json:
              schema:
                type: object
                title: ExecInspectResponse
                properties:
                  CanRemove:
                    type: boolean
                  DetachKeys:
                    type: string
                  ID:
                    type: string
                  Running:
                    type: boolean
                  ExitCode:
                    type: integer
                  ProcessConfig:
                    $ref: '#/components/schemas/ProcessConfig'
                  OpenStdin:
                    type: boolean
                  OpenStderr:
                    type: boolean
                  OpenStdout:
                    type: boolean
                  ContainerID:
                    type: string
                  Pid:
                    type: integer
                    description: The system process ID for the exec process.
              example:
                CanRemove: false
                ContainerID: b53ee82b53a40c7dca428523e34f741f3abc51d9f297a14ff874bf761b995126
                DetachKeys: ''
                ExitCode: 2
                ID: f33bbfb39f5b142420f4759b2348913bd4a8d1a6d7fd56499cb41a1bb91d7b3b
                OpenStderr: true
                OpenStdin: true
                OpenStdout: true
                ProcessConfig:
                  arguments:
                  - -c
                  - exit 2
                  entrypoint: sh
                  privileged: false
                  tty: true
                  user: '1000'
                Running: false
                Pid: 42000
        404:
          description: No such exec instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        500:
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      parameters:
      - name: id
        in: path
        description: Exec instance ID
        required: true
        schema:
          type: string
      tags:
      - Exec
components:
  schemas:
    ErrorResponse:
      description: Represents an error.
      type: object
      required:
      - message
      properties:
        message:
          description: The error message.
          type: string
      example:
        message: Something went wrong.
    ProcessConfig:
      type: object
      properties:
        privileged:
          type: boolean
        user:
          type: string
        tty:
          type: boolean
        entrypoint:
          type: string
        arguments:
          type: array
          items:
            type: string
    IDResponse:
      description: Response to an API call that returns just an Id
      type: object
      x-go-name: IDResponse
      required:
      - Id
      properties:
        Id:
          description: The id of the newly created object.
          type: string