How can I increase the listen queue size beyond 128 on a docker image with a read only file system?
When I run my container I get the following error:
uWSGI: - Listen queue size is greater than the system max net.core.somaxconn (128).
I have a Dockerfile with base image python:2.7. 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 uwsgi: your server socket listen backlog is limited to 100 connections.
I tried adding these RUN
commands to the Dockerfile:
echo 4096 > /proc/sys/net/core/somaxconn
sysctl -w net.core.somaxconn=4096
But these both fail with the following errors respectively:
/bin/sh: 1: cannot create /proc/sys/net/core/somaxconn: Read-only file system
sysctl: setting key "net.core.somaxconn": Read-only file system
I also tried mounting a file to overwrite the /proc/sys/net/core/somaxconn
and that failed with the error cannot be mounted because it is located inside "/proc"
I also tried running sudo sysctl -w net.core.somaxconn=4096
net.core.somaxconn = 4096
on the host before running, but it isn't reflected in the docker container; uwsgi still fails with the error uWSGI: - Listen queue size is greater than the system max net.core.somaxconn (128)
and running cat /proc/sys/net/core/somaxconn
shows 128 in the container while showing 4096 on the host.
You either need to run Docker in privileged mode than you can modify the /proc
file system after the container was started or you upgrade to a newer Docker release. run
subcommand has the --sysctl
option, which allows to make the change you envision:
$ docker run -ti --sysctl net.core.somaxconn=4096 --rm ubuntu /bin/bash
root@9e850908ddb7:/# sysctl net.core.somaxconn
net.core.somaxconn = 4096
If you prefer using docker-compose
. Here's the configuration that you want to adjust:
sysctls:
net.core.somaxconn: 1024
Or
sysctls:
- net.core.somaxconn=1024
Reference: https://github.com/compose-spec/compose-spec/blob/master/spec.md#sysctls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With