If I run the redis:alpine Docker image using the commmand
docker run redis:alpine
I see several warnings:
1:C 08 May 08:29:32.3
Bad way to handle things: /proc
is read-only filesystem to modify it you can run Docker in privileged mode than you can modify it after the container was started.
If running the container in privileged mode, you can disable THP using these commands:
# echo never > /sys/kernel/mm/transparent_hugepage/enabled
# echo never > /sys/kernel/mm/transparent_hugepage/defrag
Proper way: Ensure that you run newer versions of Docker (upgrade if needed). run
subcommand has the --sysctl option:
$ docker run -ti --sysctl net.core.somaxconn=4096 --rm redis:alpine /bin/sh
root@9e850908ddb7:/# sysctl net.core.somaxconn
net.core.somaxconn = 4096
...
Unfortunately: vm.overcommit_memory
is currently not allowed to be set via --sysctl
paramter the same applies to THP (transparent_hugepage), this is because they are not namespaced. Thus to fix these warning in a container running on a Linux Host you can change them directly on host. Here the related Issues:
You don't need privileged mode for the proper way approach.