Docker container receives SIGKILL/exit 137 under sustained CPU load on cgroup v2 host despite ample host free memory
Environment
Ubuntu 22.04 host, kernel 5.15 with cgroup v2 enabled (systemd managing cgroups), Docker Engine 24.0, containers run with --cpus=2 --memory=4g. Processes inside container performing heavy CPU-bound tasks and allocating ephemeral memory buffers. Swap is disabled on host. Observed on multiple containers across two hosts.
Symptoms
Occasional abrupt container termination with exit code 137 / kernel OOM killer SIGKILL. Host shows available memory free and cached; dmesg occasionally shows 'memory cgroup out of memory' messages referencing the container's cgroup path. Container had memory limit set but host had unused physical RAM.
Observations
dmesg logs: 'memory cgroup out of memory: Kill process 12345 (node) score 1000 or sacrifice child' followed by 'oom_kill_process'. cat /sys/fs/cgroup/<container>/memory.current shows spikes exceeding memory.high but under memory.max for short periods. systemd-cgroup settings show memory.high configured by Docker to a value lower than memory.max. No host-wide OOM events apart from those container-specific kills.
Already attempted
Increased container --memory to 8g on a test instance and observed fewer kills but still occasional OOM events under prolonged load. Set --oom-kill-disable=false (default) and monitored: same behavior. Monitored memory.current and memory.swap.current under stress. Tried enabling swap on host (temporary small swapfile) — reduced frequency of kills. Upgraded kernel to latest 5.15 patch release (no change).
Question
Is the likely cause cgroup v2 memory controller enforcing memory.high vs memory.max semantics under CPU/memory pressure, or an actual kernel OOM due to host fragmentation? What safe diagnostic steps can I run to confirm controller enforcement and mitigate without disabling crucial protections?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Cloud Computing33% match
Kubernetes pods OOMKilled while node shows 80GB free memory on Ubuntu 20.04 (kubelet+Docker cgroup mismatch suspected)
Open0 answers - Linux32% match
Docker containers report 'no space left on device' after systemd tmpfiles cleaned /var/lib/docker metadata despite free disk space
Open1 answer - Linux31% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer - Linux31% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer - Virtualization27% match
Docker containers lose DNS resolution after laptop resume on Ubuntu 22.04 due to systemd-resolved stub resolver change
Open0 answers