Interview Prep/Docker/Resources, health checks, logging and restarts

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.

All Docker questions Roadmap: Docker & containers

More on Resources, health checks, logging and restarts