5

I have 2 Docker containers running on Centos machine

for Docker memory monitoring purpose, I have installed "cadvisor" on the machine via Docker images

when I compare "Docker stats" and "cadvisor" value then I see that cadvisor shows more memory usage than docker stats

for example, the value of memory usage in Docker stats command for one container is 520 MiB but in cadvisor value is 756 MiB

Which one is right ?

Devendra
  • 185
  • 14
  • Well , both actually show the statistics on that instance , how are you determining that the stats from cAdvisor co-relates with the stats from docker for the same instance of time. – fatcook Mar 12 '19 at 11:52
  • I have integrated cadvisor with grafana and created a graph for it. On that graph, I am seeing the different value (756MiB) and on the instance when I typed "docker stats" I see the different value (520MiB) for the same container at the same time – Devendra Mar 12 '19 at 13:28
  • Grafana would provide you a cumulative stats for a configured period such as 1m,5m etc , i dont think you can compare this with docker stats – fatcook Mar 13 '19 at 10:20

1 Answers1

11

According to Docker docs:

On Linux, the Docker CLI reports memory usage by subtracting page cache usage from the total memory usage.

https://docs.docker.com/engine/reference/commandline/stats/

So, to get from cAdvisor the same value as docker stats show, you can use the following expression: container_memory_usage_bytes - container_memory_cache

I tried it out and got exactly the same values as docker stats produces.

amoskaliov
  • 739
  • 4
  • 10