Search or ask Docker

Update a container

POST /containers/{id}/update — Docker Engine API 1.57.

View Markdown
POST/containers/{id}/update
Change various configuration options of a container without having to recreate it.

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"
}

Request and responses

Request

application/json

All constraints apply

Schema: Resources

Type: object

RestartPolicy

Schema: RestartPolicy

All schema constraints and annotations
{
  "properties": {
    "RestartPolicy": {
      "$ref": "#/components/schemas/RestartPolicy"
    }
  },
  "type": "object"
}
All schema constraints and annotations
{
  "allOf": [
    {
      "$ref": "#/components/schemas/Resources"
    },
    {
      "properties": {
        "RestartPolicy": {
          "$ref": "#/components/schemas/RestartPolicy"
        }
      },
      "type": "object"
    }
  ],
  "example": {
    "BlkioWeight": 300,
    "CpuPeriod": 100000,
    "CpuQuota": 50000,
    "CpuRealtimePeriod": 1000000,
    "CpuRealtimeRuntime": 10000,
    "CpuShares": 512,
    "CpusetCpus": "0,1",
    "CpusetMems": "0",
    "Memory": 314572800,
    "MemoryReservation": 209715200,
    "MemorySwap": 514288000,
    "RestartPolicy": {
      "MaximumRetryCount": 4,
      "Name": "on-failure"
    }
  }
}

Schema example

{
  "BlkioWeight": 300,
  "CpuPeriod": 100000,
  "CpuQuota": 50000,
  "CpuRealtimePeriod": 1000000,
  "CpuRealtimeRuntime": 10000,
  "CpuShares": 512,
  "CpusetCpus": "0,1",
  "CpusetMems": "0",
  "Memory": 314572800,
  "MemoryReservation": 209715200,
  "MemorySwap": 514288000,
  "RestartPolicy": {
    "MaximumRetryCount": 4,
    "Name": "on-failure"
  }
}

Response 200

The container has been updated.

application/json

Schema: ContainerUpdateResponse

Response 404

no such container

application/json

Schema: ErrorResponse

Example

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

Response 500

server error

application/json

Schema: ErrorResponse

Schema example

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

Referenced schemas

#/components/schemas/ContainerUpdateResponse

#/components/schemas/ErrorResponse

#/components/schemas/Resources

#/components/schemas/RestartPolicy

Complete operation contract
{
  "description": "Change various configuration options of a container without having to\nrecreate it.\n",
  "operationId": "ContainerUpdate",
  "parameters": [
    {
      "description": "ID or name of the container",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "allOf": [
            {
              "$ref": "#/components/schemas/Resources"
            },
            {
              "properties": {
                "RestartPolicy": {
                  "$ref": "#/components/schemas/RestartPolicy"
                }
              },
              "type": "object"
            }
          ],
          "example": {
            "BlkioWeight": 300,
            "CpuPeriod": 100000,
            "CpuQuota": 50000,
            "CpuRealtimePeriod": 1000000,
            "CpuRealtimeRuntime": 10000,
            "CpuShares": 512,
            "CpusetCpus": "0,1",
            "CpusetMems": "0",
            "Memory": 314572800,
            "MemoryReservation": 209715200,
            "MemorySwap": 514288000,
            "RestartPolicy": {
              "MaximumRetryCount": 4,
              "Name": "on-failure"
            }
          }
        }
      }
    },
    "required": true,
    "x-codegen-request-body-name": "update"
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ContainerUpdateResponse"
          }
        }
      },
      "description": "The container has been updated."
    },
    "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": "Update a container",
  "tags": [
    "Container"
  ]
}