在使用Docker时,在Redis启动时解决警告的正确方法是什么?

时间:2016-12-05 12:11:54

标签: docker redis

当我运行我的Redis Docker镜像时,我会面临以下警告:

# 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 > /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.

在我在互联网上找到的解决方案中,this one看起来涵盖了所有内容,但是当我在Docker范围内尝试它时(例如:更改我的Dockerfile以应用它们),我得到错误"阅读 - 只有文件系统"。手动示例给出了同样的问题:

[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' >> /etc/sysctl.conf
[root@769368ed0fc5 /]# sysctl vm.overcommit_memory=1
sysctl: setting key "vm.overcommit_memory": Read-only file system
[root@769368ed0fc5 /]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
bash: /sys/kernel/mm/transparent_hugepage/enabled: Read-only file system
[root@769368ed0fc5 /]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
bash: /sys/kernel/mm/transparent_hugepage/enabled: Read-only file system

有谁知道如何以正确的方式修复 ?我找到了许多解决方法,例如:

  • 以特权模式运行容器
  • 将主机/ proc安装在容器中
  • 使用主机网络堆栈(--net = host)

我想知道在Docker中处理它的正确方法是什么。将提供有关提议的解决方案的技术解释的答案。

0 个答案:

没有答案