Skip to content

Commit b511d1f

Browse files
committed
chroot: remount everything as private in new mntns
If parent of the destination path is shared, this path will be unmounted from the parent ns even if the path itself is private. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
1 parent 2c620d0 commit b511d1f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/chrootarchive/chroot_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ func chroot(path string) (err error) {
2626
return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
2727
}
2828

29-
if err := mount.MakeRPrivate(path); err != nil {
29+
// make everything in new ns private
30+
if err := mount.MakeRPrivate("/"); err != nil {
31+
return err
32+
}
33+
// ensure path is a mountpoint
34+
if err := mount.MakePrivate(path); err != nil {
3035
return err
3136
}
3237

0 commit comments

Comments
 (0)