title: What is the correct way to resolve warnings at Redis startup when using Docker?
body: <p>When I run my Redis Docker image, I face these warnings:</p>
  
  <pre><code># Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
  ( ... )
  # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
  ( ... )
  # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never &gt; /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
  </code></pre>
  
  <p>Among the solutions I found in the internet, <a href="https://www.techandme.se/performance-tips-for-redis-cache-server/" rel="nofollow noreferrer">this one</a> looks cover everything, but when I try it in Docker scope (Eg.: changing my Dockerfile to apply them), I get the error "Read-only file system". Manually example give me the same issues:  </p>
  
  <pre><code>[root@769368ed0fc5 /]# sysctl -w net.core.somaxconn=65535
  sysctl: setting key "net.core.somaxconn": Read-only file system
  [root@769368ed0fc5 /]# echo 'vm.overcommit_memory = 1' &gt;&gt; /etc/sysctl.conf
  [root@769368ed0fc5 /]# sysctl vm.overcommit_memory=1
  sysctl: setting key "vm.overcommit_memory": Read-only file system
  [root@769368ed0fc5 /]# echo never &gt; /sys/kernel/mm/transparent_hugepage/enabled
  bash: /sys/kernel/mm/transparent_hugepage/enabled: Read-only file system
  [root@769368ed0fc5 /]# echo never &gt; /sys/kernel/mm/transparent_hugepage/enabled
  bash: /sys/kernel/mm/transparent_hugepage/enabled: Read-only file system
  </code></pre>
  
  <p>Does anyone know how to fix it <strong>in a proper way</strong>? I have found a lot of tricks to workaround it, like:</p>
  
  <ul>
  <li>Run container in privileged mode</li>
  <li>Mount host /proc inside a container</li>
  <li>Use host network stack (--net=host) 
  
  <ul>
  <li>Looks like this one is inevitable, because <a href="https://redis.io/topics/cluster-tutorial" rel="nofollow noreferrer">Redis doesn't support NATed environments</a>, but anyway it doesn't solve everything.</li>
  </ul></li>
  </ul>
  
  <p>I want to know what is the correct way to deal with it in Docker. Answers that provide technical explanation about the proposed solution will be appreciated.</p>