diff --git a/libcontainer/configs/config.go b/libcontainer/configs/config.go index 4b298e1ea..7fd311db4 100644 --- a/libcontainer/configs/config.go +++ b/libcontainer/configs/config.go @@ -92,8 +92,8 @@ type Config struct { // bind mounts are writtable. Readonlyfs bool `json:"readonlyfs"` - // Privatefs will mount the container's rootfs as private where mount points from the parent will not propogate - Privatefs bool `json:"privatefs"` + // Specifies the mount propagation flags to be applied to /. + RootPropagation int `json:"rootPropagation"` // Mounts specify additional source and destination paths that will be mounted inside the container's // rootfs and mount namespace if specified diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go index f95669759..f8fc90fd1 100644 --- a/libcontainer/rootfs_linux.go +++ b/libcontainer/rootfs_linux.go @@ -422,8 +422,8 @@ func mknodDevice(dest string, node *configs.Device) error { func prepareRoot(config *configs.Config) error { flag := syscall.MS_SLAVE | syscall.MS_REC - if config.Privatefs { - flag = syscall.MS_PRIVATE | syscall.MS_REC + if config.RootPropagation != 0 { + flag = config.RootPropagation } if err := syscall.Mount("", "/", "", uintptr(flag), ""); err != nil { return err diff --git a/spec.go b/spec.go index 8604121bd..90876d7ce 100644 --- a/spec.go +++ b/spec.go @@ -329,11 +329,11 @@ func createLibcontainerConfig(cgroupName string, spec *specs.LinuxSpec, rspec *s rootfsPath = filepath.Join(cwd, rootfsPath) } config := &configs.Config{ - Rootfs: rootfsPath, - Capabilities: spec.Linux.Capabilities, - Readonlyfs: spec.Root.Readonly, - Hostname: spec.Hostname, - Privatefs: true, + Rootfs: rootfsPath, + Capabilities: spec.Linux.Capabilities, + Readonlyfs: spec.Root.Readonly, + Hostname: spec.Hostname, + RootPropagation: syscall.MS_PRIVATE | syscall.MS_REC, } for _, ns := range rspec.Linux.Namespaces { t, exists := namespaceMapping[ns.Type]