title: docker container increase listen queue size beyond 128
body: <p>How can I increase the listen queue size beyond 128 on a docker image with a read only file system?</p>
  
  <p>When I run my container I get the following error:</p>
  
  <p><code>uWSGI: - Listen queue size is greater than the system max net.core.somaxconn (128).</code></p>
  
  <p>I have a Dockerfile with base image <a href="https://hub.docker.com/_/python/" rel="noreferrer" title="python:2.7">python:2.7</a>.  I am trying to increase system level limit on Unix socket and TCP connection listen queue so that uwsgi can set a listen queue limit of 1024, as described at <a href="https://stackoverflow.com/questions/12340047/uwsgi-your-server-socket-listen-backlog-is-limited-to-100-connections">uwsgi: your server socket listen backlog is limited to 100 connections</a>.</p>
  
  <p>I tried adding these <code>RUN</code> commands to the Dockerfile:</p>
  
  <ul>
  <li><code>echo 4096 &gt; /proc/sys/net/core/somaxconn</code></li>
  <li><code>sysctl -w net.core.somaxconn=4096</code></li>
  </ul>
  
  <p>But these both fail with the following errors respectively:</p>
  
  <ul>
  <li><code>/bin/sh: 1: cannot create /proc/sys/net/core/somaxconn: Read-only file system</code></li>
  <li><code>sysctl: setting key "net.core.somaxconn": Read-only file system</code></li>
  </ul>
  
  <p>I also tried mounting a file to overwrite the <code>/proc/sys/net/core/somaxconn</code> and that failed with the error <code>cannot be mounted because it is located inside "/proc"</code></p>
  
  <p>I also tried running <code>sudo sysctl -w net.core.somaxconn=4096
  net.core.somaxconn = 4096</code> on the host before running, but it isn't reflected in the docker container; uwsgi still fails with the error <code>uWSGI: - Listen queue size is greater than the system max net.core.somaxconn (128)</code> and running <code>cat /proc/sys/net/core/somaxconn</code> shows 128 in the container while showing 4096 on the host.</p>