From 1c145a39e0588bb442d91c18c65514589f4efbe0 Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Sat, 6 Jun 2026 12:05:52 -0400 Subject: [PATCH 1/2] feat: add blkio device options to docker container update Closes #3325 Related to https://github.com/moby/moby/pull/52651 Signed-off-by: Alexis Couvreur --- cli/command/container/update.go | 41 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/cli/command/container/update.go b/cli/command/container/update.go index 3bc11412e19a..de6dcff84ada 100644 --- a/cli/command/container/update.go +++ b/cli/command/container/update.go @@ -17,6 +17,7 @@ import ( type updateOptions struct { blkioWeight uint16 + blkioWeightDevice opts.WeightdeviceOpt cpuPeriod int64 cpuQuota int64 cpuRealtimePeriod int64 @@ -24,6 +25,10 @@ type updateOptions struct { cpusetCpus string cpusetMems string cpuShares int64 + deviceReadBps opts.ThrottledeviceOpt + deviceWriteBps opts.ThrottledeviceOpt + deviceReadIOps opts.ThrottledeviceOpt + deviceWriteIOps opts.ThrottledeviceOpt memory opts.MemBytes memoryReservation opts.MemBytes memorySwap opts.MemSwapBytes @@ -58,6 +63,7 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command { flags := cmd.Flags() flags.Uint16Var(&options.blkioWeight, "blkio-weight", 0, `Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)`) + flags.Var(&options.blkioWeightDevice, "blkio-weight-device", "Block IO weight (relative device weight)") flags.Int64Var(&options.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period") flags.Int64Var(&options.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota") flags.Int64Var(&options.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds") @@ -67,6 +73,10 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command { flags.StringVar(&options.cpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)") flags.StringVar(&options.cpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)") flags.Int64VarP(&options.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)") + flags.Var(&options.deviceReadBps, "device-read-bps", "Limit read rate (bytes per second) from a device") + flags.Var(&options.deviceReadIOps, "device-read-iops", "Limit read rate (IO per second) from a device") + flags.Var(&options.deviceWriteBps, "device-write-bps", "Limit write rate (bytes per second) to a device") + flags.Var(&options.deviceWriteIOps, "device-write-iops", "Limit write rate (IO per second) to a device") flags.VarP(&options.memory, "memory", "m", "Memory limit") flags.Var(&options.memoryReservation, "memory-reservation", "Memory soft limit") flags.Var(&options.memorySwap, "memory-swap", `Swap limit equal to memory plus swap: -1 to enable unlimited swap`) @@ -110,19 +120,24 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, options *updateOption updateConfig := client.ContainerUpdateOptions{ Resources: &containertypes.Resources{ - BlkioWeight: options.blkioWeight, - CpusetCpus: options.cpusetCpus, - CpusetMems: options.cpusetMems, - CPUShares: options.cpuShares, - Memory: options.memory.Value(), - MemoryReservation: options.memoryReservation.Value(), - MemorySwap: options.memorySwap.Value(), - CPUPeriod: options.cpuPeriod, - CPUQuota: options.cpuQuota, - CPURealtimePeriod: options.cpuRealtimePeriod, - CPURealtimeRuntime: options.cpuRealtimeRuntime, - NanoCPUs: options.cpus.Value(), - PidsLimit: pidsLimit, + BlkioWeight: options.blkioWeight, + BlkioWeightDevice: options.blkioWeightDevice.GetList(), + BlkioDeviceReadBps: options.deviceReadBps.GetList(), + BlkioDeviceWriteBps: options.deviceWriteBps.GetList(), + BlkioDeviceReadIOps: options.deviceReadIOps.GetList(), + BlkioDeviceWriteIOps: options.deviceWriteIOps.GetList(), + CpusetCpus: options.cpusetCpus, + CpusetMems: options.cpusetMems, + CPUShares: options.cpuShares, + Memory: options.memory.Value(), + MemoryReservation: options.memoryReservation.Value(), + MemorySwap: options.memorySwap.Value(), + CPUPeriod: options.cpuPeriod, + CPUQuota: options.cpuQuota, + CPURealtimePeriod: options.cpuRealtimePeriod, + CPURealtimeRuntime: options.cpuRealtimeRuntime, + NanoCPUs: options.cpus.Value(), + PidsLimit: pidsLimit, }, RestartPolicy: &restartPolicy, } From 0649cdb5f02a59cb3966d0ebf7c794d7ab3f1bdb Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Sat, 6 Jun 2026 14:58:23 -0400 Subject: [PATCH 2/2] add documentation Signed-off-by: Alexis Couvreur --- .../reference/commandline/container_update.md | 5 +++ docs/reference/commandline/update.md | 37 +++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/docs/reference/commandline/container_update.md b/docs/reference/commandline/container_update.md index 051c1b0a22ed..45cdda9fe766 100644 --- a/docs/reference/commandline/container_update.md +++ b/docs/reference/commandline/container_update.md @@ -12,6 +12,7 @@ Update configuration of one or more containers | Name | Type | Default | Description | |:---------------------------------------------------|:----------|:--------|:-----------------------------------------------------------------------------| | `--blkio-weight` | `uint16` | `0` | Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) | +| `--blkio-weight-device` | `list` | | Block IO weight (relative device weight) | | `--cpu-period` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) period | | `--cpu-quota` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) quota | | `--cpu-rt-period` | `int64` | `0` | Limit the CPU real-time period in microseconds | @@ -20,6 +21,10 @@ Update configuration of one or more containers | `--cpus` | `decimal` | | Number of CPUs | | `--cpuset-cpus` | `string` | | CPUs in which to allow execution (0-3, 0,1) | | `--cpuset-mems` | `string` | | MEMs in which to allow execution (0-3, 0,1) | +| `--device-read-bps` | `list` | | Limit read rate (bytes per second) from a device | +| `--device-read-iops` | `list` | | Limit read rate (IO per second) from a device | +| `--device-write-bps` | `list` | | Limit write rate (bytes per second) to a device | +| `--device-write-iops` | `list` | | Limit write rate (IO per second) to a device | | [`-m`](#memory), [`--memory`](#memory) | `bytes` | `0` | Memory limit | | `--memory-reservation` | `bytes` | `0` | Memory soft limit | | `--memory-swap` | `bytes` | `0` | Swap limit equal to memory plus swap: -1 to enable unlimited swap | diff --git a/docs/reference/commandline/update.md b/docs/reference/commandline/update.md index 60557bdbfb1a..b6cae6242eae 100644 --- a/docs/reference/commandline/update.md +++ b/docs/reference/commandline/update.md @@ -9,22 +9,27 @@ Update configuration of one or more containers ### Options -| Name | Type | Default | Description | -|:-----------------------|:----------|:--------|:-----------------------------------------------------------------------------| -| `--blkio-weight` | `uint16` | `0` | Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) | -| `--cpu-period` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) period | -| `--cpu-quota` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) quota | -| `--cpu-rt-period` | `int64` | `0` | Limit the CPU real-time period in microseconds | -| `--cpu-rt-runtime` | `int64` | `0` | Limit the CPU real-time runtime in microseconds | -| `-c`, `--cpu-shares` | `int64` | `0` | CPU shares (relative weight) | -| `--cpus` | `decimal` | | Number of CPUs | -| `--cpuset-cpus` | `string` | | CPUs in which to allow execution (0-3, 0,1) | -| `--cpuset-mems` | `string` | | MEMs in which to allow execution (0-3, 0,1) | -| `-m`, `--memory` | `bytes` | `0` | Memory limit | -| `--memory-reservation` | `bytes` | `0` | Memory soft limit | -| `--memory-swap` | `bytes` | `0` | Swap limit equal to memory plus swap: -1 to enable unlimited swap | -| `--pids-limit` | `int64` | `0` | Tune container pids limit (set -1 for unlimited) | -| `--restart` | `string` | | Restart policy to apply when a container exits | +| Name | Type | Default | Description | +|:------------------------|:----------|:--------|:-----------------------------------------------------------------------------| +| `--blkio-weight` | `uint16` | `0` | Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) | +| `--blkio-weight-device` | `list` | | Block IO weight (relative device weight) | +| `--cpu-period` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) period | +| `--cpu-quota` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) quota | +| `--cpu-rt-period` | `int64` | `0` | Limit the CPU real-time period in microseconds | +| `--cpu-rt-runtime` | `int64` | `0` | Limit the CPU real-time runtime in microseconds | +| `-c`, `--cpu-shares` | `int64` | `0` | CPU shares (relative weight) | +| `--cpus` | `decimal` | | Number of CPUs | +| `--cpuset-cpus` | `string` | | CPUs in which to allow execution (0-3, 0,1) | +| `--cpuset-mems` | `string` | | MEMs in which to allow execution (0-3, 0,1) | +| `--device-read-bps` | `list` | | Limit read rate (bytes per second) from a device | +| `--device-read-iops` | `list` | | Limit read rate (IO per second) from a device | +| `--device-write-bps` | `list` | | Limit write rate (bytes per second) to a device | +| `--device-write-iops` | `list` | | Limit write rate (IO per second) to a device | +| `-m`, `--memory` | `bytes` | `0` | Memory limit | +| `--memory-reservation` | `bytes` | `0` | Memory soft limit | +| `--memory-swap` | `bytes` | `0` | Swap limit equal to memory plus swap: -1 to enable unlimited swap | +| `--pids-limit` | `int64` | `0` | Tune container pids limit (set -1 for unlimited) | +| `--restart` | `string` | | Restart policy to apply when a container exits |