Reputation: 8610
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?
Upvotes: 5
Views: 11087
Reputation: 28987
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 ....
Upvotes: 10