Search or ask Docker

Remove a container

DELETE /containers/{id} — Docker Engine API 1.57.

View Markdown
DELETE/containers/{id}

Connection and access

API connection and authentication guidance

/v1.57

No HTTP authentication requirement is declared for this operation. Transport access controls can still apply.

Parameters

id path Required

ID or name of the container

Type: string

All schema constraints and annotations
{
  "type": "string"
}

v query

Remove anonymous volumes associated with the container.

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

force query

If the container is running, kill it before removing it.

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

link query

Remove the specified link associated with the container.

Type: boolean

All schema constraints and annotations
{
  "default": false,
  "type": "boolean"
}

Request and responses

Response 204

no error

No response content is declared.

Response 400

bad parameter

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Response 404

no such container

application/json

Schema: ErrorResponse

Example

{
  "message": "No such container: c2ada9df5af8"
}

Response 409

conflict

application/json

Schema: ErrorResponse

Example

{
  "message": "You cannot remove a running container: c2ada9df5af8. Stop the\ncontainer before attempting removal or force remove\n"
}

Response 500

server error

application/json

Schema: ErrorResponse

Schema example

{
  "message": "Something went wrong."
}

Referenced schemas

#/components/schemas/ErrorResponse

Complete operation contract
{
  "operationId": "ContainerDelete",
  "parameters": [
    {
      "description": "ID or name of the container",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "Remove anonymous volumes associated with the container.",
      "in": "query",
      "name": "v",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "If the container is running, kill it before removing it.",
      "in": "query",
      "name": "force",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Remove the specified link associated with the container.",
      "in": "query",
      "name": "link",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    }
  ],
  "responses": {
    "204": {
      "description": "no error"
    },
    "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"
    },
    "409": {
      "content": {
        "application/json": {
          "example": {
            "message": "You cannot remove a running container: c2ada9df5af8. Stop the\ncontainer before attempting removal or force remove\n"
          },
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "conflict"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "server error"
    }
  },
  "summary": "Remove a container",
  "tags": [
    "Container"
  ]
}