I have an application running inside Docker requires Huge-page to run .Now I tried following set of command for same.
CMD ["mkdir", "-p" ,"/dev/hugepages"]
CMD ["mount" ,"-t", "hugetlbfs" , "none", "/dev/hugepages"]
CMD ["echo 512" ,">" ,"/proc/sys/vm/nr_hugepages"]
CMD ["mount"]
But I don't see Hugepages gets mounted from mout command, why?
Could anyone please point me out, is it possible to do it?
Alternatively you can run a docker container with network settings set to host . Such a container will share the network stack with the docker host and from the container point of view, localhost (or 127.0.0.1 ) will refer to the docker host.
HugePages configuration allows a Pod to access memory pages larger than the Linux kernel's default memory page size, which is usually 4 KB. Many memory-intensive applications, like Elasticsearch and Cassandra, take advantage of using huge pages.
There's a number of things at hand;
First of all, a Dockerfile only has a single command (CMD
); what you're doing won't work; if you need to do multiple steps when the container is started, consider using an entrypoint script, for example this is the entrypoint script of the official mysql image
Second, doing mount
in a container requires additional privileges. You can use --privileged
but that is probably far too wide of a step, and gives far too much privileges to the container. You can try running the container with --cap-add SYS_ADMIN
in stead.
A much cleaner solution could be to mount hugepages on the host, and give the container access to that device, e.g.;
docker run --device=/dev/hugepages:/dev/hugepages ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With