Transparent Huge Pages is required to be disabled for the TokuDB engine and for Redis. With docker-toolbox, I could just docker-machine ssh
into the host and disable it. I no longer have access to the host OS, so how do I disable it?
Asked
Active
Viewed 6,747 times
5
2 Answers
3
You can actually do this with a privileged container in Docker For Mac/Windows. You can do it like this:
docker run -ti --privileged ubuntu /bin/bash
echo never | tee /sys/kernel/mm/transparent_hugepage/enabled
echo never | tee /sys/kernel/mm/transparent_hugepage/defrag
I ended up creating an image for this and made redis/mariadb include it under depends_on in my docker-compose.yml file
FROM ubuntu:latest
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
where docker-entrypoint.sh has:
#!/bin/bash
set -e
echo never | tee /sys/kernel/mm/transparent_hugepage/enabled
echo never | tee /sys/kernel/mm/transparent_hugepage/defrag

Root Fool
- 324
- 2
- 11
-
1Running a container as privileged allows the container to access the host and isn't generally a good idea for security reasons. There is a post here about how to log into the VM in Docker for Mac, but it seems a bit of a hack: https://forums.docker.com/t/docker-for-mac-how-to-set-host-settings-sysctl-etc/11168 I'm not aware of an official way of doing this yet. – foz Mar 07 '17 at 10:05
-
What is the advantage (if any) of using the `echo ... | tee
` pattern over simply `echo ... > – cueedee Aug 15 '23 at 08:26` ?
2
An even easier solution is to create file profile with content
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
and add following line to Dockerfile
COPY profile /var/lib/boot2docker/profile

Coolius
- 53
- 1
- 6
-
do you mean that the image generated by this dockerfile the one used as the docker_compose depends_on? – Rene Wooller Nov 27 '19 at 06:07