diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index 4ed0594c6a..3402f77790 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 e7fcb257b6..1689f90cc0 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 }