Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable Transparent Hugepages for Docker for Mac/Windows (Native)

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?

like image 344
Root Fool Avatar asked Jul 20 '16 18:07

Root Fool


2 Answers

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
like image 170
Root Fool Avatar answered Oct 19 '22 10:10

Root Fool


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
like image 2
Coolius Avatar answered Oct 19 '22 08:10

Coolius