How to fix the WARNINGs when running the redis:alpine Docker image

后端 未结 1 1152
长情又很酷
长情又很酷 2021-02-05 15:26

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         


        
相关标签:
1条回答
  • 2021-02-05 16:09

    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:

    • #19
    • #55

    You don't need privileged mode for the proper way approach.

    0 讨论(0)
提交回复
热议问题