Update a container Run in API Explorer

POST /containers/{id}/update

Change various configuration options of a container without having to recreate it.

Path parameters

  • id string Required

    ID or name of the container

application/json

Body Required

  • CpuShares integer

    An integer value representing this container's relative CPU weight versus other containers.

  • Memory integer(int64)

    Memory limit in bytes.

    Default value is 0.

  • CgroupParent string

    Path to cgroups under which the container's cgroup is created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups are created if they do not already exist.

  • BlkioWeight integer

    Block IO weight (relative weight).

    Minimum value is 0, maximum value is 1000.

  • BlkioWeightDevice array[object]

    Block IO weight (relative device weight) in the form:

    [{"Path": "device_path", "Weight": weight}]
    
    Hide BlkioWeightDevice attributes Show BlkioWeightDevice attributes object
    • Path string
    • Weight integer

      Minimum value is 0.

  • BlkioDeviceReadBps array[object]

    Limit read rate (bytes per second) from a device, in the form:

    [{"Path": "device_path", "Rate": rate}]
    
    Hide BlkioDeviceReadBps attributes Show BlkioDeviceReadBps attributes object
    • Path string

      Device path

    • Rate integer(int64)

      Rate

      Minimum value is 0.

  • BlkioDeviceWriteBps array[object]

    Limit write rate (bytes per second) to a device, in the form:

    [{"Path": "device_path", "Rate": rate}]
    
    Hide BlkioDeviceWriteBps attributes Show BlkioDeviceWriteBps attributes object
    • Path string

      Device path

    • Rate integer(int64)

      Rate

      Minimum value is 0.

  • BlkioDeviceReadIOps array[object]

    Limit read rate (IO per second) from a device, in the form:

    [{"Path": "device_path", "Rate": rate}]
    
    Hide BlkioDeviceReadIOps attributes Show BlkioDeviceReadIOps attributes object
    • Path string

      Device path

    • Rate integer(int64)

      Rate

      Minimum value is 0.

  • BlkioDeviceWriteIOps array[object]

    Limit write rate (IO per second) to a device, in the form:

    [{"Path": "device_path", "Rate": rate}]
    
    Hide BlkioDeviceWriteIOps attributes Show BlkioDeviceWriteIOps attributes object
    • Path string

      Device path

    • Rate integer(int64)

      Rate

      Minimum value is 0.

  • CpuPeriod integer(int64)

    The length of a CPU period in microseconds.

  • CpuQuota integer(int64)

    Microseconds of CPU time that the container can get in a CPU period.

  • CpuRealtimePeriod integer(int64)

    The length of a CPU real-time period in microseconds. Set to 0 to allocate no time allocated to real-time tasks.

  • CpuRealtimeRuntime integer(int64)

    The length of a CPU real-time runtime in microseconds. Set to 0 to allocate no time allocated to real-time tasks.

  • CpusetCpus string

    CPUs in which to allow execution (e.g., 0-3, 0,1).

  • CpusetMems string

    Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.

  • Devices array[object]

    A list of devices to add to the container.

    A device mapping between the host and container

    Hide Devices attributes Show Devices attributes object
    • PathOnHost string
    • PathInContainer string
    • CgroupPermissions string
  • DeviceCgroupRules array[string]

    a list of cgroup rules to apply to the container

  • DeviceRequests array[object]

    A list of requests for devices to be sent to device drivers.

    A request for devices to be sent to device drivers

    Hide DeviceRequests attributes Show DeviceRequests attributes object
    • Driver string
    • Count integer
    • DeviceIDs array[string]
    • Capabilities array[array]

      A list of capabilities; an OR list of AND lists of capabilities.

    • Options object

      Driver-specific options, specified as a key/value pairs. These options are passed directly to the driver.

      Hide Options attribute Show Options attribute object
      • * string Additional properties
  • KernelMemoryTCP integer(int64)

    Hard limit for kernel TCP buffer memory (in bytes). Depending on the OCI runtime in use, this option may be ignored. It is no longer supported by the default (runc) runtime.

    This field is omitted when empty.

  • MemoryReservation integer(int64)

    Memory soft limit in bytes.

  • MemorySwap integer(int64)

    Total memory limit (memory + swap). Set as -1 to enable unlimited swap.

  • MemorySwappiness integer(int64)

    Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.

    Minimum value is 0, maximum value is 100.

  • NanoCpus integer(int64)

    CPU quota in units of 10-9 CPUs.

  • OomKillDisable boolean

    Disable OOM Killer for the container.

  • Init boolean

    Run an init inside the container that forwards signals and reaps processes. This field is omitted if empty, and the default (as configured on the daemon) is used.

  • PidsLimit integer(int64)

    Tune a container's PIDs limit. Set 0 or -1 for unlimited, or null to not change.

  • Ulimits array[object]

    A list of resource limits to set in the container. For example:

    {"Name": "nofile", "Soft": 1024, "Hard": 2048}
    
    Hide Ulimits attributes Show Ulimits attributes object
    • Name string

      Name of ulimit

    • Soft integer

      Soft limit

    • Hard integer

      Hard limit

  • CpuCount integer(int64)

    The number of usable CPUs (Windows only).

    On Windows Server containers, the processor resource controls are mutually exclusive. The order of precedence is CPUCount first, then CPUShares, and CPUPercent last.

  • CpuPercent integer(int64)

    The usable percentage of the available CPUs (Windows only).

    On Windows Server containers, the processor resource controls are mutually exclusive. The order of precedence is CPUCount first, then CPUShares, and CPUPercent last.

  • IOMaximumIOps integer(int64)

    Maximum IOps for the container system drive (Windows only)

  • IOMaximumBandwidth integer(int64)

    Maximum IO in bytes per second for the container system drive (Windows only).

  • RestartPolicy object

    The behavior to apply when the container exits. The default is not to restart.

    An ever increasing delay (double the previous delay, starting at 100ms) is added before each restart to prevent flooding the server.

    Hide RestartPolicy attributes Show RestartPolicy attributes object
    • Name string
      • Empty string means not to restart
      • no Do not automatically restart
      • always Always restart
      • unless-stopped Restart always except when the user has manually stopped the container
      • on-failure Restart only when the container exit code is non-zero

      Values are , no, always, unless-stopped, or on-failure.

    • MaximumRetryCount integer

      If on-failure is used, the number of times to retry before giving up.

Responses

  • 200 application/json

    The container has been updated.

    Hide response attribute Show response attribute object
    • Warnings array[string]
  • 404 application/json

    no such container

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 500 application/json

    server error

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

POST /containers/{id}/update
curl \
 --request POST 'http://api.example.com/v1.44/containers/{id}/update' \
 --header "Content-Type: application/json" \
 --data '{"Memory":314572800,"CpuQuota":50000,"CpuPeriod":100000,"CpuShares":512,"CpusetCpus":"0,1","CpusetMems":"0","MemorySwap":514288000,"BlkioWeight":300,"RestartPolicy":{"Name":"on-failure","MaximumRetryCount":4},"CpuRealtimePeriod":1000000,"MemoryReservation":209715200,"CpuRealtimeRuntime":10000}'
Request examples
{
  "Memory": 314572800,
  "CpuQuota": 50000,
  "CpuPeriod": 100000,
  "CpuShares": 512,
  "CpusetCpus": "0,1",
  "CpusetMems": "0",
  "MemorySwap": 514288000,
  "BlkioWeight": 300,
  "RestartPolicy": {
    "Name": "on-failure",
    "MaximumRetryCount": 4
  },
  "CpuRealtimePeriod": 1000000,
  "MemoryReservation": 209715200,
  "CpuRealtimeRuntime": 10000
}
Response examples (200)
{
  "Warnings": [
    "string"
  ]
}
Response examples (404)
{
  "message": "No such container: c2ada9df5af8"
}
Response examples (404)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}