For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/default_rules/wys-u76-jdp.md. A documentation index is available at /llms.txt.

The critical containers should be configured to remain responsive

docker

Classification:

compliance

Framework:

cis-docker

Control:

5.12

Description

Containers should have their CPU shares set.

Rationale

CPU shares weigh the containers against each other when the CPU is busy. Set on purpose, they keep a busy container from slowing the critical ones.

Audit

Inspect the containers:

docker ps --quiet --all | xargs docker inspect --format '{{ .Name }}: CpuShares={{ .HostConfig.CpuShares }}'

Datadog passes the rule when a container’s CPU shares are set to a value other than 0 and 1024 (the default weight), and fails it otherwise.

Remediation

Run the container with --cpu-shares:

docker run --cpu-shares 512 <image>

Impact

A container with a low weight gets less CPU when the host is busy.

Default value

Every container has the same weight, 1024.

References

  1. https://docs.docker.com/engine/containers/resource_constraints/#cpu
  2. https://docs.docker.com/reference/cli/docker/container/run/#options
  3. https://docs.docker.com/engine/containers/runmetrics/