dockerdocker-composeboot2dockerhuge-pages

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?


Solution

  • 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