Search or ask Docker

Delete unused images

POST /images/prune — Docker Engine API 1.57.

View Markdown
POST/images/prune

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

filters query

Filters to process on the prune list, encoded as JSON (a map[string][]string). Available filters:

  • dangling=<boolean> When set to true (or 1), prune only unused and untagged images. When set to false (or 0), all unused images are pruned.
  • until=<string> Prune images created before this timestamp. The <timestamp> can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time.
  • label (label=<key>, label=<key>=<value>, label!=<key>, or label!=<key>=<value>) Prune images with (or without, in case label!=... is used) the specified labels.

Type: string

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

Request and responses

Response 200

No error

application/json

Type: object

ImagesDeleted

Type: array

Images that were deleted
Array item

Schema: ImageDeleteResponseItem

All schema constraints and annotations
{
  "description": "Images that were deleted",
  "items": {
    "$ref": "#/components/schemas/ImageDeleteResponseItem"
  },
  "type": "array"
}
SpaceReclaimed

Type: integer

Disk space reclaimed in bytes
All schema constraints and annotations
{
  "description": "Disk space reclaimed in bytes",
  "format": "int64",
  "type": "integer"
}
All schema constraints and annotations
{
  "properties": {
    "ImagesDeleted": {
      "description": "Images that were deleted",
      "items": {
        "$ref": "#/components/schemas/ImageDeleteResponseItem"
      },
      "type": "array"
    },
    "SpaceReclaimed": {
      "description": "Disk space reclaimed in bytes",
      "format": "int64",
      "type": "integer"
    }
  },
  "title": "ImagePruneResponse",
  "type": "object"
}

Response 500

Server error

application/json

Schema: ErrorResponse

Schema example

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

Referenced schemas

#/components/schemas/ErrorResponse

#/components/schemas/ImageDeleteResponseItem

Complete operation contract
{
  "operationId": "ImagePrune",
  "parameters": [
    {
      "description": "Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters:\n\n- `dangling=\u003cboolean\u003e` When set to `true` (or `1`), prune only\n   unused *and* untagged images. When set to `false`\n   (or `0`), all unused images are pruned.\n- `until=\u003cstring\u003e` Prune images created before this timestamp. The `\u003ctimestamp\u003e` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time.\n- `label` (`label=\u003ckey\u003e`, `label=\u003ckey\u003e=\u003cvalue\u003e`, `label!=\u003ckey\u003e`, or `label!=\u003ckey\u003e=\u003cvalue\u003e`) Prune images with (or without, in case `label!=...` is used) the specified labels.\n",
      "in": "query",
      "name": "filters",
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "ImagesDeleted": {
                "description": "Images that were deleted",
                "items": {
                  "$ref": "#/components/schemas/ImageDeleteResponseItem"
                },
                "type": "array"
              },
              "SpaceReclaimed": {
                "description": "Disk space reclaimed in bytes",
                "format": "int64",
                "type": "integer"
              }
            },
            "title": "ImagePruneResponse",
            "type": "object"
          }
        }
      },
      "description": "No error"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Server error"
    }
  },
  "summary": "Delete unused images",
  "tags": [
    "Image"
  ]
}