Prevent a fork bomb in a container.
IntermediateScenarioLimits, logging, health checks and restarts
Answer
Situation read → Unbounded PIDs can exhaust the host process table.
What I'd do → docker run --pids-limit 256 ... and a daemon default via "default-pids-limit" where supported. Add --ulimit nofile=65536:65536 for file descriptors.
Why → The pids cgroup controller stops fork calls beyond the limit.
Interview tip → Test with :(){ :|:& };: in a sandbox.
More on Limits, logging, health checks and restarts
A Java container is OOM-killed at 512 MB. Why isn't the heap the whole story?IntermediateHow do you cap CPU and memory for a container and what happens on exceed?BeginnerLatency spikes though CPU usage looks low (50%).Advanced`docker logs` is empty but the app is running.BeginnerConfigure log rotation globally.BeginnerShip container logs to a central system.Intermediate