How to enable huge page support in a Dockerfile

I'm building a dockerfile for an app that requires huge page support

vm.nr_hugepages=128

inside /etc/sysctl.conf

How do I achieve that in a Dockerfile? I tried run sudo sysctl -w vm.nr_hugepages=128 but it didn't work apparently


Configure HugeTlbPage on the host system and make sure it is mounted under /dev/hugepages directory.

Then give your container access to it by mapping the mount point to /dev/hugepages on the container.

You can bind mount a volume using -v option or --device to add a host device to the container. You’ll have docker run command like this:

# docker run -v /dev/hugepages:/dev/hugepages ....

Or

# docker run --device=/dev/hugepages:/dev/hugepages ...