Process ulimits and open file descriptors
Linux resource limits (rlimits) constrain individual processes or particular user-scoped resources. --ulimit nofile=256:512 sets the soft and hard open-file descriptor limits for the container process. Sockets and pipes use descriptors too, so a connection-heavy program can hit this limit without running out of memory.
Worked example
This is an offline lesson. Scenarios are fictional and Docker commands are unexecuted. Any optional execution requires an approved disposable VM, a reviewed preloaded image with verified digest, blocked external access and appropriate resource limits. No resource exhaustion or host-policy change is required. Before any authorized optional observation, verify the effective daemon endpoint including overrides, exact object ID and observation window. Bound collection time and output bytes; do not generate resource pressure or export private telemetry. Mark unavailable measurements NOT RUN.
Fictional nofile budgetsoft=256, hard=512base descriptors=32100 simultaneous connections x 2 descriptors=200projected=232; remaining=24A soft limit is the active threshold; an unprivileged process can normally adjust it up to its hard limit. An attempt to open another descriptor beyond the soft limit may fail with EMFILE. Hard limits cannot ordinarily be raised by an unprivileged process. Check /proc/PID/limits for the actual process on an authorized Linux environment. nproc has user-scoped semantics and is not a substitute for the container PID controller. Fix descriptor leaks, bound connection pools and size the limit with evidence; do not open descriptors until failure in a shared host. The nofile limit applies per process, not to the total of all container processes. The worksheet assumes one process owns the counted descriptors: 32 + 110 × 2 = 252, leaving four, not sixteen. For a multi-process service budget each process separately and consider system-wide descriptor capacity.
Common mistake
nofile does not limit the number of files stored on disk.
Manual practice
Calculate the projected descriptors for 110 connections with the same base and per-connection cost; decide whether it leaves 16 spare descriptors.
Worksheet: lab-fixtures/docker-resource-management/05-ulimits/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Process ulimits and open file descriptors — Knowledge check
Apply resource management reasoning in a fictional scenario.
For one process configured with nofile=256:512, which limit is active?
Which resource consumes descriptors?
Why not use nproc as the sole container task ceiling?