Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run: block PODMAN_USERNS and --pod #18601

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/source/markdown/options/userns.container.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
####> are applicable to all of those.
#### **--userns**=*mode*

Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options.
Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable unless `--pod` is specified. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options.

This option is incompatible with **--gidmap**, **--uidmap**, **--subuidname** and **--subgidname**.

Expand Down
6 changes: 3 additions & 3 deletions pkg/specgenutil/specgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ func setNamespaces(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions)
return err
}
}
userns := os.Getenv("PODMAN_USERNS")
if c.UserNS != "" {
userns = c.UserNS
userns := c.UserNS
if userns == "" && c.Pod == "" {
userns = os.Getenv("PODMAN_USERNS")
}
// userns must be treated differently
if userns != "" {
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/run_userns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ var _ = Describe("Podman UserNS support", func() {
inspect.WaitWithDefaultTimeout()
Expect(inspect.OutputToString()).To(Not(Equal("<nil>")))

// --pod should work.
result = podmanTest.Podman([]string{"create", "--pod=new:new-pod", ALPINE, "true"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))

if IsRemote() {
podmanTest.RestartRemoteService()
}
Expand Down