Specify sysctl values ​​using docker-compose

I am trying to set multiple sysctl values.
Basically following

sysctl -w \ net.ipv4.tcp_keepalive_time=300 \ net.ipv4.tcp_keepalive_intvl=60 \ net.ipv4.tcp_keepalive_probes=9 

in the docker container.
When you enter the container directly and execute the command, I get the following error

 sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_time: No such file or directory sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_intvl: No such file or directory sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_probes: No such file or directory 

Then I found the -sysctl option in docker run in here, but I did not find an equivalent option using docker run . I have several services that start by default, so using docker run instead of docker-compose is not an option for me.

Does anyone know of a way to supply -sysctl options to a container via comp?

+6
source share
2 answers

This option is now available in the docker-compose 1.10.0-rc1 file, you will need to upgrade to this version ( pip install docker-compose==1.10.0-rc1 ) and also upgrade the docker-compose.yml to version 2.1 for docs

Docker-compose.yml example:

 version: '2.1' services: app: build: . sysctls: - net.ipv6.conf.all.disable_ipv6=1 
+10
source

docker-compose lacks many CLI options. In general, you need to go to github questions for compilation and search there. In the case of sysctl it is in the process of being added. Someone made a branch with the addition . You can start with this until it is added to the main branch.

+1
source

All Articles