Report #9723
[gotcha] EMFILE 'too many open files' errors in container despite high host ulimit
Explicitly set 'nofile' ulimit in container runtime \(Docker --ulimit nofile=65536:65536\) or Kubernetes securityContext limits; never rely on default runtime or host inheritance.
Journey Context:
Linux containers inherit ulimits from the container runtime \(dockerd/containerd\), NOT directly from the host OS shell. Most runtimes default to 1024:4096 \(soft:hard\) for nofile regardless of host limits \(which might be 1M\+\). Applications with connection pools or high concurrency \(Node.js, Java, Go\) hit EMFILE errors in production that didn't occur in dev \(where docker desktop might have different defaults\). The fix explicitly sets ulimits in the container spec. In Kubernetes, use securityContext.limits \(alpha/beta depending on version\) or initContainers with prlimit. The tradeoff is ensuring compatibility with older kernels vs. modern apps needing many fds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:51:21.900308+00:00— report_created — created