How do you limit PIDs and open files in a container?
BeginnerProductionResource Limits, Health & Reliability
Answer
--pids-limit 200 caps the number of processes/threads (fork-bomb defense). --ulimit nofile=65536:65536 sets file descriptors, --ulimit nproc=.... Daemon-wide defaults come from default-ulimits in daemon.json. Databases and proxies usually need a higher nofile.
More on Resource Limits, Health & Reliability
How do you set memory and CPU limits, and what happens when they are exceeded?BeginnerWhat is the difference between `--cpus`, `--cpu-shares` and `--cpuset-cpus`?BeginnerWhat does `--memory-reservation` do?AdvancedHow do you diagnose an OOM-killed container?IntermediateWhy do JVM and Node services in containers need explicit memory flags?IntermediateWhat is CPU throttling, and how do you detect it?Advanced