How to fix WARNINGS when starting redis: alpine Docker image

If I run the Redis image: Alpine Docker using the command

docker run redis:alpine

      

I see several warnings:

1:C 08 May 08:29:32.308 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
                _._                                                  
           _.-''__ ''-._                                             
      _.-''    '.  '_.  ''-._           Redis 3.2.8 (00000000/0) 64 bit
  .-'' .-'''.  '''\/    _.,_ ''-._                                   
 (    '      ,       .-'  | ',    )     Running in standalone mode
 |'-._'-...-' __...-.''-._|'' _.-'|     Port: 6379
 |    '-._   '._    /     _.-'    |     PID: 1
  '-._    '-._  '-./  _.-'    _.-'                                   
 |'-._'-._    '-.__.-'    _.-'_.-'|                                  
 |    '-._'-._        _.-'_.-'    |           http://redis.io        
  '-._    '-._'-.__.-'_.-'    _.-'                                   
 |'-._'-._    '-.__.-'    _.-'_.-'|                                  
 |    '-._'-._        _.-'_.-'    |                                  
  '-._    '-._'-.__.-'_.-'    _.-'                                   
      '-._    '-.__.-'    _.-'                                       
          '-._        _.-'                                           
              '-.__.-'                                               

1:M 08 May 08:29:32.311 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 08 May 08:29:32.311 # Server started, Redis version 3.2.8
1:M 08 May 08:29:32.311 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 08 May 08:29:32.311 # 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 > /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.
1:M 08 May 08:29:32.311 * The server is now ready to accept connections on port 6379

      

I tried to fix the first two of these warnings using the following Dockerfile

:

FROM redis:alpine
COPY somaxconn /proc/sys/net/core/somaxconn
COPY sysctl.conf /etc/sysctl.conf
CMD ["redis-server", "--appendonly", "yes"]

      

where my local file somaxconn

contains one entry 511

and sysctl.conf

contains string vm.overcommit_memory = 1

. However, I still get the same warnings when building and starting the container.

How can I get rid of these warnings? (There are mentions of the problems at https://www.techandme.se/performance-tips-for-redis-cache-server/, but the solution described there, which involves changing rc.local , seems to apply to the Rasperry Pi).

+9


source to share


1 answer


Bad way to handle things : /proc

is a read-only filesystem, to change it you can run Docker in privileged mode than you can change it after starting the container.

If the container is running in privileged mode, you can disable THP with the following commands:

# echo never > /sys/kernel/mm/transparent_hugepage/enabled
# echo never > /sys/kernel/mm/transparent_hugepage/defrag

      

Correct way : make sure you are using newer versions of Docker (update if necessary). the subcommand run

has a --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

currently cannot be set via parameter --sysctl

the same applies to THP (transparent_hugepage), this is because they are not a namespace. So, to fix these warnings in a container running on a Linux host, you can change them directly on the host. Here are the related questions:

You don't need privileged mode to do the right thing .

+9


source







All Articles