Docker Community Forums

Share and learn in the Docker community.

How docker stats measure CPU and RAM?

I am running several containers, all of them ran on the same base which is Debian, each containers ran a different C++ application. When i tried to measure their CPU usage, i noticed that there is a different between Cpu usage took by Htop versus what took by Docker stats. IMO, it would be the CPU usage of container’s OS and Docker base. But what i want to ask here is that the difference value above varied wildly among my containers (in one container it’s 0.5%, in other container it’s 10%)
I thought if they use the same base (Debian), then that different value should be the same.
Could anyone explain for me how Docker stats works and how Docker uses CPU so that i can understand what had happened?