From 9126b45a3f2255b103ef60f305f8ca9ab2805b50 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 10 Sep 2018 17:00:24 -0400 Subject: [PATCH] Up default Podman rlimits to avoid max open files Every port we open consumes an open FD. This can easily consume all available FDs for the podman process. Set rlimits to resolve this. Signed-off-by: Matthew Heon Closes: #1437 Approved by: rhatdan --- cmd/podman/main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/podman/main.go b/cmd/podman/main.go index 8d470e10da..48032a20e3 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -138,6 +138,17 @@ func main() { logrus.SetLevel(level) } + // Only if not rootless, set rlimits for open files. + // We open numerous FDs for ports opened + if os.Geteuid() == 0 { + rlimits := new(syscall.Rlimit) + rlimits.Cur = 1048576 + rlimits.Max = 1048576 + if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil { + return errors.Wrapf(err, "error setting new rlimits") + } + } + if logLevel == "debug" { debug = true