Skip to content

Commit e83d366

Browse files
committed
volumes: add new option idmap
pass down the "idmap" mount option to the OCI runtime. Needs: containers/crun#780 Closes: containers#12154 [NO NEW TESTS NEEDED] there is no crun version yet that support the new feature. Test case (must run as root): podman run --rm -v foo:/foo alpine touch /foo/bar podman run --uidmap 0:1:1000 --rm -v foo:/foo:idmap alpine ls -l /foo total 0 -rw-r--r-- 1 root root 0 Nov 15 14:01 bar Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent 9b96494 commit e83d366

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,9 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
606606

607607
· ro, readonly: true or false (default).
608608

609-
. 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.
609+
. 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.
610+
611+
· idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container.
610612

611613
Options specific to image:
612614

@@ -622,7 +624,9 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
622624

623625
. relabel: shared, private.
624626

625-
. 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.
627+
· idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container.
628+
629+
. 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.
626630

627631
Options specific to tmpfs:
628632

@@ -636,7 +640,7 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
636640

637641
· notmpcopyup: Disable copying files from the image to the tmpfs.
638642

639-
. 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.
643+
. 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.
640644

641645
Options specific to devpts:
642646

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,9 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
633633

634634
· ro, readonly: true or false (default).
635635

636-
. 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.
636+
. 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.
637+
638+
· idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container.
637639

638640
Options specific to image:
639641

@@ -649,7 +651,9 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
649651

650652
. relabel: shared, private.
651653

652-
. 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.
654+
· idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container.
655+
656+
. 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.
653657

654658
Options specific to tmpfs:
655659

@@ -663,7 +667,7 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and
663667

664668
· notmpcopyup: Disable copying files from the image to the tmpfs.
665669

666-
. 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.
670+
. 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.
667671

668672
Options specific to devpts:
669673

pkg/specgenutil/volumes.go

+2
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ func getBindMount(args []string) (spec.Mount, error) {
355355
newMount.Options = append(newMount.Options, "U")
356356
}
357357
setOwnership = true
358+
case "idmap":
359+
newMount.Options = append(newMount.Options, "idmap")
358360
case "consistency":
359361
// Often used on MACs and mistakenly on Linux platforms.
360362
// Since Docker ignores this option so shall we.

pkg/util/mountOpts.go

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
3333
// Some options have parameters - size, mode
3434
splitOpt := strings.SplitN(opt, "=", 2)
3535
switch splitOpt[0] {
36+
case "idmap":
3637
case "O":
3738
if len(options) > 1 {
3839
return nil, errors.Wrapf(ErrDupeMntOption, "'O' option can not be used with other options")

0 commit comments

Comments
 (0)