Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose 3 sysctls directive unsupported

I have a sysctls setting in docker-compose file, but as I understood, this directive is ignored in version 3:

sysctls:
        - net.core.somaxconn = 65536
        - net.ipv4.tcp_max_tw_buckets = 1440000
        - net.ipv4.ip_local_port_range = 1024 65000
        - net.ipv4.tcp_fin_timeout = 15
        - net.ipv4.tcp_window_scaling = 1
        - net.ipv4.tcp_max_syn_backlog = 3240000
        - fs.file-max = 20480

I need to find another way to set these parameters, but I can't exactly figure out how from the docs (tried RUN and CMD), and I need a clear example showing how to do this. I understand that normally from the command line it goes like this:

sudo sysctl -w net.core.somaxconn=65536

Thanks.

like image 746
Mister_L Avatar asked Nov 08 '22 20:11

Mister_L


1 Answers

With version 3 docker-compose file, the option still works with docker-compose, but it does not work in docker swarm.

This option is ignored when deploying a stack in swarm mode with a (version 3) Compose file.

This is because sysctl reads and modifies the attributes of the system kernel, so running it in a container does not make sense. It's logical that docker swarm does not support it anymore because if you have 2 stacks / docker-compose.yml all using this instruction, there would be conflict.

So the only way to do it is to run the command on the host machine.

like image 115
Siyu Avatar answered Nov 15 '22 07:11

Siyu