Skip to main content

Module docker_resource_limits

Module docker_resource_limits 

Source
Expand description

Docker resource limits that must survive a resume (issue #176).

docker commit captures a container’s filesystem and image config, but not its HostConfig. A snapshot-based resume ($ --resume <id> -- <cmd>) used to start the replacement container without the memory, CPU and PIDs limits the original one had — limits a supervisor typically applied with docker update, so they were never part of the stored launch options.

This module reads the limits back out of docker inspect and translates the non-default ones into docker run flags. The flags are kept in the --flag=value form, so the same list is stored in the execution record, shown in [Isolation] status lines, and spliced into docker run as is.

Constants§

DEFAULT_SHM_SIZE
Docker’s default /dev/shm size; only a different size is re-applied.

Functions§

build_resource_limits_status_line
[Isolation] status line for resource limits, or None when there are none.
cpu_count
An existing quota/period cannot be changed to Docker NanoCPUs in place.
cpu_update_args
format_docker_bytes
Format a byte count with the largest binary unit docker run accepts that represents it exactly (268435456 → 256m).
format_docker_cpus
Format NanoCpus as the decimal --cpus value (500000000 → 0.5).
normalize_resource_limits
Normalize a stored resourceLimits value (array or whitespace-separated string) to a list of flags.
parse_docker_resource_limits
Translate an inspected HostConfig into docker run flags.
read_docker_resource_limits
Read a container’s resource limits with docker inspect.
with_cpu_limit