# Attach to a container via a websocket


[API catalog](/reference/api/) · [Docker Engine overview](/reference/api/engine/version/v1.57/) · [Product manual](https://docs.docker.com/engine/) · [OpenAPI specification](/reference/api/engine/version/v1.57.yaml)

API version: 1.57





`GET /containers/{id}/attach/ws`



## Connection and access

[API connection and authentication guidance](/reference/api/engine/version/v1.57/#connection)


Server: `/v1.57`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
null
```


This operation upgrades the HTTP connection. Use a client that supports the protocol described for this operation.


## Parameters

### id

Location: path. Required: yes.

ID or name of the container

```json
{
  "description": "ID or name of the container",
  "in": "path",
  "name": "id",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### detachKeys

Location: query. Required: no.

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 `_`.


```json
{
  "description": "Override the key sequence for detaching a container.Format is a single\ncharacter `[a-Z]` or `ctrl-\u003cvalue\u003e` where `\u003cvalue\u003e` is one of: `a-z`,\n`@`, `^`, `[`, `,`, or `_`.\n",
  "in": "query",
  "name": "detachKeys",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/1",
  "schema": {
    "type": "string"
  }
}
```

### logs

Location: query. Required: no.

Return logs

```json
{
  "description": "Return logs",
  "in": "query",
  "name": "logs",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/2",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### stream

Location: query. Required: no.

Return stream

```json
{
  "description": "Return stream",
  "in": "query",
  "name": "stream",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/3",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### stdin

Location: query. Required: no.

Attach to `stdin`

```json
{
  "description": "Attach to `stdin`",
  "in": "query",
  "name": "stdin",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/4",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### stdout

Location: query. Required: no.

Attach to `stdout`

```json
{
  "description": "Attach to `stdout`",
  "in": "query",
  "name": "stdout",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/5",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### stderr

Location: query. Required: no.

Attach to `stderr`

```json
{
  "description": "Attach to `stderr`",
  "in": "query",
  "name": "stderr",
  "pointer": "/paths/~1containers~1{id}~1attach~1ws/get/parameters/6",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

## Request and responses

### Response 101 application/json

no error, hints proxy about hijacking











### Response 101 text/plain

no error, hints proxy about hijacking











### Response 200 application/json

no error, no upgrade header found











### Response 200 text/plain

no error, no upgrade header found











### Response 400 application/json

bad parameter


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 404 application/json

no such container


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Example:
```json
{
  "message": "No such container: c2ada9df5af8"
}
```


### Response 500 application/json

server error


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


## Complete operation contract

```json
{
  "operationId": "ContainerAttachWebsocket",
  "parameters": [
    {
      "description": "ID or name of the container",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "Override the key sequence for detaching a container.Format is a single\ncharacter `[a-Z]` or `ctrl-\u003cvalue\u003e` where `\u003cvalue\u003e` is one of: `a-z`,\n`@`, `^`, `[`, `,`, or `_`.\n",
      "in": "query",
      "name": "detachKeys",
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "Return logs",
      "in": "query",
      "name": "logs",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Return stream",
      "in": "query",
      "name": "stream",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Attach to `stdin`",
      "in": "query",
      "name": "stdin",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Attach to `stdout`",
      "in": "query",
      "name": "stdout",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Attach to `stderr`",
      "in": "query",
      "name": "stderr",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    }
  ],
  "responses": {
    "101": {
      "content": {
        "application/json": {},
        "text/plain": {}
      },
      "description": "no error, hints proxy about hijacking"
    },
    "200": {
      "content": {
        "application/json": {},
        "text/plain": {}
      },
      "description": "no error, no upgrade header found"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "bad parameter"
    },
    "404": {
      "content": {
        "application/json": {
          "example": {
            "message": "No such container: c2ada9df5af8"
          },
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "no such container"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "server error"
    }
  },
  "summary": "Attach to a container via a websocket",
  "tags": [
    "Container"
  ]
}
```

## Referenced schemas

- [#/components/schemas/ErrorResponse](/reference/api/engine/version/v1.57/schemas/ErrorResponse/)




