LinuxCommandLibrary

docker-update

Update a container's resources and configuration

TLDR

View documentation for the original command

$ tldr docker container update
copy

SYNOPSIS

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

PARAMETERS

--blkio-weight INT
    Block IO relative weight (10-1000)

--cpu-period INT64
    CPU CFS period in nanoseconds

--cpu-quota INT64
    CPU CFS quota in nanoseconds

--cpu-rt-period INT64
    CPU realtime period in microseconds

--cpu-rt-runtime INT64
    CPU realtime runtime in microseconds

--cpus DECIMAL
    Number of CPUs available

--cpu-shares INT64
    CPU shares (relative weight)

--disable-content-trust
    Skip image verification (default true)

--help
    Print usage

--kernel-memory SIZE
    Kernel memory limit

--memory INT64|SIZE
    Memory limit

--memory-reservation INT64|SIZE
    Memory soft limit

--memory-swap INT64|SIZE
    Total memory (memory + swap)

--pids-limit INT64
    Tune container pids limit

--restart POLICY
    Restart policy: no, on-failure, always, unless-stopped

--ulimits ULIMIT
    Ulimit options in format name=soft:hard

DESCRIPTION

The docker update command modifies the configuration of one or more running or stopped containers, primarily focusing on resource limits and restart policies. It allows dynamic adjustments to CPU, memory, block IO, and other runtime constraints without restarting the container. This is particularly useful for fine-tuning resource allocation in production environments.

For example, you can increase memory limits or adjust CPU shares for containers under heavy load. The command applies changes immediately to running containers where possible, using Linux cgroups under the hood. It supports multiple containers specified by ID or name.

Key use cases include scaling resources on the fly, enforcing restart policies like 'always' or 'unless-stopped', and setting PIDs limits to prevent fork bombs. Note that some options, like kernel memory, may not be supported in all runtimes or kernel versions. Always verify changes with docker inspect or docker stats.

CAVEATS

Changes apply only to supported runtime features; some require container restart. Cannot reduce limits below current usage. Verify with docker inspect.

EXAMPLES

docker update --cpus=2 mycontainer
docker update --memory=512m --restart=always container1 container2

REQUIREMENTS

Requires Docker daemon with cgroup support; privileged mode may be needed for some limits.

HISTORY

Introduced in Docker 1.10 (February 2016) to support live resource updates via cgroups v1/v2. Enhanced in later versions for runtime compatibility.

SEE ALSO

Copied to clipboard