Container's CPU usage inside `top` differs from `docker stats`.
AdvancedTroubleshootingResources, health checks, logging and restarts
Answer
Likely causes → top inside shows host-level /proc/stat data (no lxcfs), while docker stats reads cgroup accounting.
Diagnose → Compare docker stats with cat /sys/fs/cgroup/cpu.stat deltas.
Fix → Trust cgroup metrics (cAdvisor); use nproc/cgroup files for in-app sizing.
Prevent → Monitoring based on cgroup metrics, not in-container top.
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