From 907c7c17f04f140ded24fdbdd5b79ce6f3e8ab2a Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Fri, 10 Apr 2015 10:45:04 -0400 Subject: [PATCH] Change mount point propogation to default to slave As an admin I would expect that if I volume mount a partition into a container, and then later add a mount point to the volume, it will show up in the container. Docker-DCO-1.1-Signed-off-by: Dan Walsh (github: rhatdan) --- configs/config.go | 3 +++ rootfs_linux.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configs/config.go b/configs/config.go index b07f252b5..1f5a55d3b 100644 --- a/configs/config.go +++ b/configs/config.go @@ -37,6 +37,9 @@ 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"` + // Mounts specify additional source and destination paths that will be mounted inside the container's // rootfs and mount namespace if specified Mounts []*Mount `json:"mounts"` diff --git a/rootfs_linux.go b/rootfs_linux.go index 38ed032dd..091dc431d 100644 --- a/rootfs_linux.go +++ b/rootfs_linux.go @@ -248,9 +248,9 @@ func mknodDevice(dest string, node *configs.Device) error { } func prepareRoot(config *configs.Config) error { - flag := syscall.MS_PRIVATE | syscall.MS_REC - if config.NoPivotRoot { - flag = syscall.MS_SLAVE | syscall.MS_REC + flag := syscall.MS_SLAVE | syscall.MS_REC + if config.Privatefs { + flag = syscall.MS_PRIVATE | syscall.MS_REC } if err := syscall.Mount("", "/", "", uintptr(flag), ""); err != nil { return err