What's memory shown in docker stats really mean?

Viewed 1057

1) I use next to start a container:

docker run --name test -idt python:3 python -m http.server

2) Then, I try to validate memory usage like next:

a)
root@shubuntu1:~# ps aux | grep "python -m http.server"
root     17416  3.0  0.2  27368 19876 pts/0    Ss+  17:11   0:00 python -m http.server

b)
root@shubuntu1:~# docker exec -it test ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.9  0.2  27368 19876 pts/0    Ss+  09:11   0:00 python -m http.

c)
root@shubuntu1:~# docker stats --no-stream test
CONTAINER ID   NAME  CPU %    MEM USAGE / LIMIT     MEM %    NET I/O      BLOCK I/O   PIDS
d72f2ece6816   test  0.01%    12.45MiB / 7.591GiB   0.16%    3.04kB / 0B  0B / 0B     1

You can see from both docker host & docker container, we could see python -m http.server consume 19876/1024=19.1289MB memory (RSS), but from docker stats, I find 12.45MB, why it show container memory consume even less than the PID1 process in container?

rss        RSS      resident set size, the non-swapped physical memory that a task has used (in kiloBytes). (alias rssize, rsz).

MEM USAGE / LIMIT the total memory the container is using, and the total amount of memory it is allowed to use

0 Answers
Related