How do you set per-container ulimits and sysctls safely?
AdvancedProductionResource Limits, Health & Reliability
Answer
Only namespaced sysctls are allowed (net.* mostly, kernel.shm*, kernel.msg*): --sysctl net.core.somaxconn=4096. Non-namespaced ones (vm.max_map_count for Elasticsearch) must be set on the host. Never use --privileged just to set a sysctl.
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