Container killed by the OOM killer but `docker stats` never showed high memory.
AdvancedTroubleshootingResources, health checks, logging and restarts
Answer
Likely causes → Short spikes between sampling intervals, kernel memory/tmpfs counted in the cgroup, or sub-process memory.
Diagnose →
cat /sys/fs/cgroup/system.slice/docker-<id>.scope/memory.events
cat .../memory.peak
dmesg -T | grep -B2 -A10 'Memory cgroup out of memory'
Fix → Raise the limit by the observed memory.peak, reduce spikes (batch size, parallelism).
Prevent → Alert on memory.events oom_kill counters.
More on Resources, health checks, logging and restarts
Container restarts repeatedly: `docker ps` shows `Restarting (1) 5 seconds ago`.Beginner`OOMKilled: true` and exit code 137.BeginnerContainer is `unhealthy` but the app works when tested manually.Intermediate`docker stats` shows 100%+ CPU and the container is slow.Intermediate`docker logs` is slow or `docker logs -f` hangs on a container with huge logs.Intermediate`Error response from daemon: configured logging driver does not support reading` when running `docker logs`.Intermediate