I\'m running a web server that is handling many thousands of concurrent web socket connections. For this to be possible, on Debian linux (my base image is google/debian:wheezy,
I was able to mitgiate this issue with the following configuration :
I used ubuntu 14.04 linux for the docker machine and the host machine.
On the host machine You need to :
* - nofile 64000
fs.file-max = 64000
You can pass the limit as argument while running the container. That way you don't have to modify host's limits and give too much power to the container. Here is how:
docker run --ulimit nofile=5000:5000 <image-tag>
With docker-compose you could configure ulimits.
https://docs.docker.com/compose/compose-file/#ulimits
You can add soft/hard limits as a mapping.
ulimits:
nproc: 65535
nofile:
soft: 20000
hard: 40000
Although not ideal you could run container with privileged option (Mostly for a quick non-optimal solution for a Dev environment, not recommended if security is a concern).
docker run --privileged
Please see:
https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities