# Wait for a container


[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





`POST /containers/{id}/wait`

Block until a container stops, then returns the exit code.

## 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
```

## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --unix-socket "${DOCKER_SOCKET:-/var/run/docker.sock}" \
  --header 'Accept: application/json' \
  'http://localhost/v1.57/containers/<ID>/wait'
```



## 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}~1wait/post/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### condition

Location: query. Required: no.

Wait until a container state reaches the given condition.

Defaults to `not-running` if omitted or empty.


```json
{
  "description": "Wait until a container state reaches the given condition.\n\nDefaults to `not-running` if omitted or empty.\n",
  "in": "query",
  "name": "condition",
  "pointer": "/paths/~1containers~1{id}~1wait/post/parameters/1",
  "schema": {
    "default": "not-running",
    "enum": [
      "not-running",
      "next-exit",
      "removed"
    ],
    "type": "string"
  }
}
```

## Request and responses

### Response 200 application/json

The container has exit.


Schema:

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










### 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
{
  "description": "Block until a container stops, then returns the exit code.",
  "operationId": "ContainerWait",
  "parameters": [
    {
      "description": "ID or name of the container",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "Wait until a container state reaches the given condition.\n\nDefaults to `not-running` if omitted or empty.\n",
      "in": "query",
      "name": "condition",
      "schema": {
        "default": "not-running",
        "enum": [
          "not-running",
          "next-exit",
          "removed"
        ],
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ContainerWaitResponse"
          }
        }
      },
      "description": "The container has exit."
    },
    "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": "Wait for a container",
  "tags": [
    "Container"
  ]
}
```

## Referenced schemas

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

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




