diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go index 735d7128e87..3c714b0905e 100644 --- a/libcontainer/rootfs_linux.go +++ b/libcontainer/rootfs_linux.go @@ -723,7 +723,15 @@ func readonlyPath(path string) error { } return err } - return unix.Mount(path, path, "", unix.MS_BIND|unix.MS_REMOUNT|unix.MS_RDONLY|unix.MS_REC, "") + + statfs := unix.Statfs_t{} + if err := unix.Statfs(path, &statfs); err != nil { + return err + } + + flags := statfs.Flags | unix.MS_BIND | unix.MS_REMOUNT | unix.MS_RDONLY | unix.MS_REC + + return unix.Mount(path, path, "", uintptr(flags), "") } // remountReadonly will remount an existing mount point and ensure that it is read-only.