diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 4ed0594c6a312c7371b46c3edecb305b254a4570..3402f77790dfb47f63c1bec978b3e3333f06eac7 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -1148,6 +1148,11 @@ func setupOOMScoreAdj(score int) error { return err } _, err = f.WriteString(strconv.Itoa(score)) + if os.IsPermission(err) { + // Setting oom_score_adj does not work in an + // unprivileged container. Ignore the error. + return nil + } f.Close() return err } diff --git a/libcontainerd/remote_linux.go b/libcontainerd/remote_linux.go index e7fcb257b6224b1b4e21e5d12f0226828d1637ef..1689f90cc05456f38051fc217e6574943b7104a4 100644 --- a/libcontainerd/remote_linux.go +++ b/libcontainerd/remote_linux.go @@ -435,6 +435,11 @@ func setOOMScore(pid, score int) error { } _, err = f.WriteString(strconv.Itoa(score)) f.Close() + if os.IsPermission(err) { + // Setting oom_score_adj does not work in an + // unprivileged container. Ignore the error. + return nil + } return err }