1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #27609 from tonistiigi/fix-chroot-shared-parent

chroot: remount everything as private in new mntns
This commit is contained in:
Kenfe-Mickaël Laventure 2016-10-21 14:40:40 -07:00 committed by GitHub
commit 87ae571fed

View file

@ -26,7 +26,12 @@ func chroot(path string) (err error) {
return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
}
if err := mount.MakeRPrivate(path); err != nil {
// make everything in new ns private
if err := mount.MakeRPrivate("/"); err != nil {
return err
}
// ensure path is a mountpoint
if err := mount.MakePrivate(path); err != nil {
return err
}
@ -57,13 +62,6 @@ func chroot(path string) (err error) {
err = errCleanup
}
}
if errCleanup := syscall.Unmount("/", syscall.MNT_DETACH); errCleanup != nil {
if err == nil {
err = fmt.Errorf("error unmounting root: %v", errCleanup)
}
return
}
}()
if err := syscall.PivotRoot(path, pivotDir); err != nil {