Skip to content

Commit 4e9e6f2

Browse files
committed
volumes: allow more options for devpts
allow to pass down more options that are supported by the kernel. Discussion here: containers/toolbox#568 Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent e6286fb commit 4e9e6f2

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

docs/source/markdown/podman-create.1.md

+10
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,16 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
638638

639639
. U, chown: true or false (default). Change recursively the owner and group of the source volume based on the UID and GID of the container.
640640

641+
Options specific to devpts:
642+
643+
· uid: UID of the file owner (default 0).
644+
645+
· gid: GID of the file owner (default 0).
646+
647+
· mode: permission mask for the file (default 600).
648+
649+
· max: maximum number of PTYs (default 1048576).
650+
641651
#### **--name**=*name*
642652

643653
Assign a name to the container

docs/source/markdown/podman-run.1.md

+10
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,16 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
665665

666666
. U, chown: true or false (default). Change recursively the owner and group of the source volume based on the UID and GID of the container.
667667

668+
Options specific to devpts:
669+
670+
· uid: UID of the file owner (default 0).
671+
672+
· gid: GID of the file owner (default 0).
673+
674+
· mode: permission mask for the file (default 600).
675+
676+
· max: maximum number of PTYs (default 1048576).
677+
668678
#### **--name**=*name*
669679

670680
Assign a name to the container.

pkg/specgenutil/volumes.go

+2
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ func getDevptsMount(args []string) (spec.Mount, error) {
483483
for _, val := range args {
484484
kv := strings.SplitN(val, "=", 2)
485485
switch kv[0] {
486+
case "uid", "gid", "mode", "ptxmode", "newinstance", "max":
487+
newMount.Options = append(newMount.Options, val)
486488
case "target", "dst", "destination":
487489
if len(kv) == 1 {
488490
return newMount, errors.Wrapf(optionArgError, kv[0])

test/e2e/run_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,14 @@ USER mail`, BB)
11981198
Expect(session.OutputToString()).To(ContainSubstring("devpts"))
11991199
})
12001200

1201+
It("podman run --mount type=devpts,target=/dev/pts with uid, gid and mode", func() {
1202+
// runc doesn't seem to honor uid= so avoid testing it
1203+
session := podmanTest.Podman([]string{"run", "-t", "--mount", "type=devpts,target=/dev/pts,uid=1000,gid=1001,mode=123", fedoraMinimal, "stat", "-c%g-%a", "/dev/pts/0"})
1204+
session.WaitWithDefaultTimeout()
1205+
Expect(session).Should(Exit(0))
1206+
Expect(session.OutputToString()).To(ContainSubstring("1001-123"))
1207+
})
1208+
12011209
It("podman run --pod automatically", func() {
12021210
session := podmanTest.Podman([]string{"run", "-d", "--pod", "new:foobar", ALPINE, "nc", "-l", "-p", "8686"})
12031211
session.WaitWithDefaultTimeout()

0 commit comments

Comments
 (0)