当我对下面的yaml文件进行“ docker-compose up -d”操作时,我的redis图像会向我发出以下警告。
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.
我认为我需要以某种方式将其添加到docker-compose.yaml文件中的“命令”中,但是我不知道该怎么做。
redis:
image: redis:4.0.5-alpine
restart: always
ports:
- 6379:6379
expose:
- 6379
command: ["redis-server", "--appendonly", "yes"]
hostname: redis
networks:
- web
volumes:
- redis-data:/data
答案 0 :(得分:0)
否,transparent_hugepage
是内核功能,在编写时无法执行任何操作,应按照指示在主机系统的bash中使用root禁用它。
$ echo never > /sys/kernel/mm/transparent_hugepage/enabled
要使其在重启后也能生效,应将其写入/etc/rc.local
,它将在主机重启后再次运行。
如您所知,容器将在运行时共享主机的内核,并且在主机中禁用上述功能,您的容器也将从修改中受益。