I created a docker container from an image which is of size: ~90 MB
.
The container is running fine. I wanted to know how much RAM does a container must be using on its host machine. So I ran "docker stats" command and it shows following output:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
66c266363746 sbrconfigurator_v0_2 0.00% 32.29MiB / 740.2MiB 4.36% 0B / 0B 15.1MB / 4.1kB 10
Here it shows memory usage as followings:
MEM USAGE / LIMIT
32.29MiB / 740.2MiB
I don't know what does this 740.2 MB memory means, whether it means that 740.2 MB
of RAM has been allocated to this container i.e 740.2 MB
RAM is being used by this container or not.
Please help me know how much RAM (host's machine) does this container must be using. Host machine is Linux, Ubuntu.
The memory limit shows how much memory docker will allow the container to use before killing the container with an OOM. If you do not set the memory limit on a container, it defaults to all of the memory available on the docker host. With Docker for Win/Mac, this is memory allocated to the embedded VM which you can adjust in the settings. You can set the memory limit in the compose file, or directly on the docker run
cli:
$ docker run -itd --name test-mem -m 1g busybox /bin/sh
f2f9f041a76c0b74e4c6ae51dd57070258a06c1f3ee884d07fef5a103f0925d4
$ docker stats --no-stream test-mem
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
f2f9f041a76c test-mem 0.00% 360KiB / 1GiB 0.03% 5.39kB / 0B 3.29MB / 0B 1
In the above example, busybox is not using 1GB of memory, only 360KB.
Without setting the limit, the memory limit in GiB can be converted (GiB*1024 = KB) to show something very close to what you see in the free
command for total memory on the host. Not sure if the small difference between the two accounts for the kernel or some other overhead.