Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ func createContainer(container, image, release, authFile string, showCommandToEn
devPtsMount = []string{"--mount", "type=devpts,destination=/dev/pts"}
}

// Keep the host user's supplementary groups (eg. vboxusers) inside the
// container so that group-only device access under /dev keeps working.
// Requires Podman >= 3.2.0 where '--group-add keep-groups' was introduced
// and only makes sense for non-root (rootless) users. :contentReference[oaicite:0]{index=0}
logrus.Debug("Checking if 'podman create' supports '--group-add keep-groups'")
var keepGroups []string
if currentUser.Uid != "0" && podman.CheckVersion("3.2.0") {
logrus.Debug("'podman create' supports '--group-add keep-groups'")
keepGroups = []string{"--group-add", "keep-groups"}
}

var usernsArg string
if currentUser.Uid == "0" {
usernsArg = "host"
Expand Down Expand Up @@ -430,6 +441,9 @@ func createContainer(container, image, release, authFile string, showCommandToEn
"--dns", "none",
}

// Add '--group-add keep-groups' when available, so the container inherits
// the host user's supplementary groups (eg. vboxusers).
createArgs = append(createArgs, keepGroups...)
createArgs = append(createArgs, toolbxDelayEntryPointEnv...)
createArgs = append(createArgs, toolbxFailEntryPointEnv...)

Expand Down