LinuxCommandLibrary

docker-container-update

TLDR

Update restart policy to apply when a specific container exits

$ docker [[update|container update]] --restart [always|no|on-failure|unless-stopped] [container_name]
copy

Update the policy to restart up to three times a specific container when it exits with non-zero exit status
$ docker [[update|container update]] --restart on-failure:3 [container_name]
copy

Update the number of CPUs available to a specific container
$ docker [[update|container update]] --cpus [count] [container_name]
copy

Update the memory limit in [M]egabytes for a specific container
$ docker [[update|container update]] [[-m|--memory]] [limit]M [container_name]
copy

Update the maximum number of process IDs allowed inside a specific container (use -1 for unlimited)
$ docker [[update|container update]] --pids-limit [count] [container_name]
copy

Update the amount of memory in [M]egabytes a specific container can swap to disk (use -1 for unlimited)
$ docker [[update|container update]] --memory-swap [limit]M [container_name]
copy

SYNOPSIS

docker container update [OPTIONS] CONTAINER [CONTAINER...]

PARAMETERS

--blkio-weight <int32>
    Block IO relative weight (10-1000)

--blkio-weight-device list
    Block IO relative device weights

--cpu-period <int>
    CPU CFS period in nanoseconds

--cpu-quota <int>
    CPU CFS quota in nanoseconds

--cpu-rt-period <int>
    CPU realtime period

--cpu-rt-runtime <int>
    CPU realtime runtime

--cpus <decimal>
    Number of CPUs available

--cpuset-cpus <string>
    CPUs allowed (e.g., '0-3')

--cpuset-mems <string>
    Memory nodes allowed (e.g., '0-1')

--cpu-shares <int32>
    Relative CPU shares

--device-read-bps list
    Device read rate limit (bytes/sec)

--device-read-iops list
    Device read IOPS limit

--device-write-bps list
    Device write rate limit (bytes/sec)

--device-write-iops list
    Device write IOPS limit

--kernel-memory <bytes>
    Kernel memory limit

--memory <bytes>
    Memory limit (e.g., 512m)

--memory-reservation <bytes>
    Memory soft limit

--memory-swap <bytes>
    Total memory+swap (-1 disables)

--pids-limit <int>
    PIDs limit (-1 disables)

--restart <string>
    Restart policy (e.g., 'always')

--ulimit ulimit
    Ulimit configuration

DESCRIPTION

The docker container update command modifies the resource configuration of one or more running containers without restarting them. It allows live adjustments to CPU, memory, block IO, and other limits, making it useful for dynamic resource management in production environments.

This command supports fine-grained control over container resources, such as CPU shares, quota, period, and realtime scheduling; memory limits including swap and reservation; PIDs limits; restart policies; and device-specific IO throttling. Changes take effect immediately on supported platforms like Linux.

It requires the containers to be running; stopped containers ignore updates until restarted. Not all options are available on every Docker runtime or host OS—check platform compatibility. Use it to scale resources responsively, optimize workloads, or enforce policies without downtime.

For example, increase memory for a memory-stressed container or throttle IO for disk-intensive tasks. Always verify changes with docker stats or container inspection.

CAVEATS

Only affects running containers; ignored on stopped ones. Platform-dependent support (Linux best). Errors if invalid values or unsupported options.

EXAMPLES

Increase CPU shares: docker container update --cpu-shares 512 mycontainer
Limit memory to 1GB: docker container update --memory 1g mycontainer
Throttle device writes: docker container update --device-write-bps /dev/sda:1mb mycontainer

PLATFORM NOTES

Full support on Linux with cgroups v1/v2. Limited on macOS/Windows due to VM layers. Use docker info for cgroup version.

HISTORY

Introduced in Docker 1.10 (2016) for live resource updates. Enhanced in later versions with more options like --cpus (1.13), realtime CPU (19.03), and PIDs limit (1.13). Evolved with containerd runtime integration.

SEE ALSO

Copied to clipboard