LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

How do cgroup flags like --cpus, --pids-limit and --memory defend a host, and what attacks do they blunt?

They cap a container's CPU, process count and memory, so one container cannot exhaust the host — stopping resource-starvation, (D)DoS and fork-bomb attacks, and noisy-neighbour problems.

By default a container is unlimited — it inherits the host's limits, so a single container can consume everything and starve the others (or the host itself). cgroup flags set ceilings:

Flag Limits
--cpus 0.5 Fraction of a CPU core the container may use.
--cpuset-cpus 0 Which specific core(s) it may run on (0-3, or 0,3).
--cpu-shares 512 Relative CPU weight — only takes effect under contention; default 1024, so 512 ≈ half as much CPU time as a default container when the CPU is busy.
--pids-limit 6 Maximum number of processes — e.g. six, after which fork() fails.
--memory 256m Hard memory cap.

What they stop:

  • Fork bombs — --pids-limit means the exponential process explosion hits a wall and the rest of the system keeps running.
  • (D)DoS / runaway code — CPU and memory caps keep a hostile or buggy container from monopolising the machine.
  • Noisy neighbours — fair sharing between co-located containers.

docker stats (and htop) show the limits taking effect. cgroups protect availability; they are the resource-side complement to the capability/namespace controls that protect confidentiality and integrity.

Go deeper:

From Quiz: ISLAB / Docker Security | Updated: Dec 01, 2026