Docker Community Forums

Share and learn in the Docker community.

Setting tcp_keepalive_time param for containers


(Sambitvz) #1

Hi there,

We are running into an issue, which seems be a trivial one given the maturity of Docker framework. I could not find a reliable solution from digging around, hence this is my last hope.

We are running out production systems in DCOS, with Docker version 1.12(Commit id: d5236f0).

Goal:
We want to set the value for tcp_keepalive_time param in the container.

Approach 1:

  • Modified the docker-compose.yml.tmpl and set the value using sysctl.
    sysctls:
      - net.ipv4.tcp_keepalive_intvl=45
      - net.ipv4.tcp_keepalive_probes=15
      - net.ipv4.tcp_keepalive_time=295

Result:
Did not work. I can see the value set as the env parameter, however netstat shows that the socket is not picking up that value.

Approach 2:

  • Tried to modify the value via sysctl.
    Result:
    Failed since the procfs is a read-only file system on the container.

Can someone help me on how to set this param effectively on the container?

Thanks.


(Stephanegerber) #2

I am doing this at the moment.
For the first approach, it it working, I checked in the container /proc/sys/net/ipv4/tpc_keepalive_intvl, etc … the value is good. In the docker-compose.yml file, you have to be carfefull not to add any spaces between the key and the value.

For your second approach, you must use the privileged flag in your docker-compose.yaml, as you are modifying the kernel settings.

privileged: true