Report #46213
[gotcha] Containerized application hitting 'too many open files' despite high host limits
Explicitly set \`--ulimit nofile=65536:65536\` \(or higher\) in docker run commands or daemon.json, and verify with \`ulimit -n\` inside the container; never rely on host limits being inherited correctly
Journey Context:
Developers often assume that because the Docker host has \`ulimit -n\` set to 65535 or unlimited, containers will inherit this. However, Docker daemon applies its own default ulimits \(often 1024:4096 for nofile\) to all containers unless explicitly overridden. This manifests as 'EMFILE: too many open files' errors in high-concurrency applications \(databases, proxies, Node.js apps\) that work fine when tested directly on the host. The debugging is painful because \`/proc/sys/fs/file-max\` inside the container shows the host value, but \`ulimit -n\` shows the restricted value. The fix requires setting ulimits in docker-compose, Kubernetes securityContext \(which sets the container runtime limits\), or daemon.json. Note that Kubernetes requires privileged containers or specific annotations to raise ulimits above the hard limit, making this a deployment constraint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:02:44.731722+00:00— report_created — created