Skip to content

Commit 9523692

Browse files
Merge pull request #21487 from Romain-Geissler-1A/fix-using-docker-client-with-rootful-in-rootless-podman
Fix running container from docker client with rootful in rootless podman
2 parents c4b793f + f59a5f1 commit 9523692

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

libpod/container_internal_common.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"github.com/containers/storage/pkg/archive"
4646
"github.com/containers/storage/pkg/idtools"
4747
"github.com/containers/storage/pkg/lockfile"
48+
"github.com/containers/storage/pkg/unshare"
4849
stypes "github.com/containers/storage/types"
4950
securejoin "github.com/cyphar/filepath-securejoin"
5051
runcuser "github.com/moby/sys/user"
@@ -632,14 +633,15 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
632633
nofileSet := false
633634
nprocSet := false
634635
isRootless := rootless.IsRootless()
635-
if isRootless {
636-
if g.Config.Process != nil && g.Config.Process.OOMScoreAdj != nil {
637-
var err error
638-
*g.Config.Process.OOMScoreAdj, err = maybeClampOOMScoreAdj(*g.Config.Process.OOMScoreAdj)
639-
if err != nil {
640-
return nil, nil, err
641-
}
636+
isRunningInUserNs := unshare.IsRootless()
637+
if isRunningInUserNs && g.Config.Process != nil && g.Config.Process.OOMScoreAdj != nil {
638+
var err error
639+
*g.Config.Process.OOMScoreAdj, err = maybeClampOOMScoreAdj(*g.Config.Process.OOMScoreAdj)
640+
if err != nil {
641+
return nil, nil, err
642642
}
643+
}
644+
if isRootless {
643645
for _, rlimit := range c.config.Spec.Process.Rlimits {
644646
if rlimit.Type == "RLIMIT_NOFILE" {
645647
nofileSet = true

0 commit comments

Comments
 (0)