Search or ask Docker

Delete builder cache

POST /build/prune — Docker Engine API 1.57.

View Markdown
POST/build/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

reserved-space query

Amount of disk space in bytes to keep for cache

Type: integer

All schema constraints and annotations
{
  "format": "int64",
  "type": "integer"
}

max-used-space query

Maximum amount of disk space allowed to keep for cache

Type: integer

All schema constraints and annotations
{
  "format": "int64",
  "type": "integer"
}

min-free-space query

Target amount of free disk space after pruning

Type: integer

All schema constraints and annotations
{
  "format": "int64",
  "type": "integer"
}

all query

Remove all types of build cache

Type: boolean

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

filters query

A JSON encoded value of the filters (a map[string][]string) to process on the list of build cache objects.

Available filters:

  • until=<timestamp> remove cache older than <timestamp>. The <timestamp> can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon's local time.
  • id=<id>
  • parent=<id>
  • type=<string>
  • description=<string>
  • inuse
  • shared
  • private

Type: string

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

Request and responses

Response 200

No error

application/json

Type: object

CachesDeleted

Type: array

Array item

Type: string

ID of build cache object
All schema constraints and annotations
{
  "description": "ID of build cache object",
  "type": "string"
}
All schema constraints and annotations
{
  "items": {
    "description": "ID of build cache object",
    "type": "string"
  },
  "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": {
    "CachesDeleted": {
      "items": {
        "description": "ID of build cache object",
        "type": "string"
      },
      "type": "array"
    },
    "SpaceReclaimed": {
      "description": "Disk space reclaimed in bytes",
      "format": "int64",
      "type": "integer"
    }
  },
  "title": "BuildPruneResponse",
  "type": "object"
}

Response 500

Server error

application/json

Schema: ErrorResponse

Schema example

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

Referenced schemas

#/components/schemas/ErrorResponse

Complete operation contract
{
  "operationId": "BuildPrune",
  "parameters": [
    {
      "description": "Amount of disk space in bytes to keep for cache",
      "in": "query",
      "name": "reserved-space",
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Maximum amount of disk space allowed to keep for cache",
      "in": "query",
      "name": "max-used-space",
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Target amount of free disk space after pruning",
      "in": "query",
      "name": "min-free-space",
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    },
    {
      "description": "Remove all types of build cache",
      "in": "query",
      "name": "all",
      "schema": {
        "type": "boolean"
      }
    },
    {
      "description": "A JSON encoded value of the filters (a `map[string][]string`) to\nprocess on the list of build cache objects.\n\nAvailable filters:\n\n- `until=\u003ctimestamp\u003e` remove cache older than `\u003ctimestamp\u003e`. The `\u003ctimestamp\u003e` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time.\n- `id=\u003cid\u003e`\n- `parent=\u003cid\u003e`\n- `type=\u003cstring\u003e`\n- `description=\u003cstring\u003e`\n- `inuse`\n- `shared`\n- `private`\n",
      "in": "query",
      "name": "filters",
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "CachesDeleted": {
                "items": {
                  "description": "ID of build cache object",
                  "type": "string"
                },
                "type": "array"
              },
              "SpaceReclaimed": {
                "description": "Disk space reclaimed in bytes",
                "format": "int64",
                "type": "integer"
              }
            },
            "title": "BuildPruneResponse",
            "type": "object"
          }
        }
      },
      "description": "No error"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "Server error"
    }
  },
  "summary": "Delete builder cache",
  "tags": [
    "Image"
  ]
}