"docker run --memory" doesn't account hugepages
I am facing two problems using "docker run --memory". docker is running in privileged mode. I want to know if this behavior is expected.
I am running DPDK based application in container. My server has total 128G memory, I have limited container memory resource to 4G. which I can see in docker stats.
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS [0/18152] 4deda4634b22 my_docker 38.12% 1.455GiB / 4GiB 36.37% 1.53kB / 0B 1.94GB / 755MB 69
First problem is that i see full 128G memory inside docker.
My applications, read host available memory and based on that individual application allocate a portion of total memory. eg. I hv two applications inside docker. if total available memory inside docker is 6G. each application will work with 3G memory. if docker total memory is constraint to 4G. each application suppose to work with 2G. This scheme of allocation will not work in docker as it sees all host memory. Is there any workaround?
root@4deda4634b22:/# free -m total used free shared buff/cache available Mem: 128961 35277 75558 2051 18125 90019 Swap: 131037 5 131032 root@4deda4634b22:/#
Second problem, i am seeing that even after docker memory is constraint to 4G. application is able to allocate 32G huge pages memory along with other non huge page memory. Is it expected? Does docker run --memory option work only with non-huge page memory?
root@server# docker exec -ti my_docker bash root@4deda4634b22:/# root@4deda4634b22:/# ps aux |grep riot root 893 17.2 0.0 68345740 105260 pts/0 Sl 05:54 1:02 /app/riot <<<<<< application. root@4deda4634b22:/# cat /proc/meminfo |grep -i huge AnonHugePages: 909312 kB ShmemHugePages: 0 kB **HugePages_Total: 32** **HugePages_Free: 0** HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 1048576 kB root@4deda4634b22:/# ls -rlt /mnt/huge/* | wc -l 32