Tuukka Mustonen Tuukka Mustonen - 2 months ago 17
Linux Question

Refresh net.core.somaxcomm (or any sysctl property) for docker containers

I am trying to change

net.core.somaxconn
for docker container to be able to have larger queue of requests for my web application.

On OS, outside docker, I first modify the property successfully:

$ cat /proc/sys/net/core/somaxconn
128
$ sudo sysctl -w net.core.somaxconn=1024
net.core.somaxconn = 1024
$ cat /proc/sys/net/core/somaxconn
1024


But then I don't know how to propagate that change into docker. I've tried:


  • Also editing
    /etc/sysctl.conf
    (in hope of docker reading that file on container launch)

  • Restarting containers
    sudo docker stop
    and
    sudo docker run
    again

  • Restarting the whole docker service by
    sudo service docker restart



But inside container,
cat /proc/sys/net/core/somaxconn
always shows
128
.

I'm running docker 1.2 (so I cannot, by default, modify
/proc
attributes inside container) and in Elastic Beanstalk (so without
--privileged
mode, that would allow me to modify
/proc
).

How can I propagate the sysctl changes to docker?

Answer

Just figured out how to solve this, now Elastic Beanstalk supports running a privileged containers and you just need to add the "privileged": "true" to your Dockerrun.aws.json as the following sample (please take a look at the container-1):

{
  "AWSEBDockerrunVersion": 2,
  "containerDefinitions": [{
    "name": "container-0",
    "essential": "false",
    "image": "ubuntu",
    "memory": "512"
  }, {
    "name": "container-1",
    "essential": "false",
    "image": "ubuntu",
    "memory": "512",
    "privileged": "true"
  }]
}

Please note that I duplicated this answer from another thread.

Comments