Переглянути джерело

Merge pull request #11353 from mrunalp/override_default_mounts

Filter out default mounts that are being overriden by the user.
Jessie Frazelle 10 роки тому
батько
коміт
87a8658eb6
1 змінених файлів з 14 додано та 0 видалено
  1. 14 0
      daemon/execdriver/native/create.go

+ 14 - 0
daemon/execdriver/native/create.go

@@ -212,6 +212,20 @@ func (d *driver) setupRlimits(container *configs.Config, c *execdriver.Command)
 }
 
 func (d *driver) setupMounts(container *configs.Config, c *execdriver.Command) error {
+	userMounts := make(map[string]struct{})
+	for _, m := range c.Mounts {
+		userMounts[m.Destination] = struct{}{}
+	}
+
+	// Filter out mounts that are overriden by user supplied mounts
+	var defaultMounts []*configs.Mount
+	for _, m := range container.Mounts {
+		if _, ok := userMounts[m.Destination]; !ok {
+			defaultMounts = append(defaultMounts, m)
+		}
+	}
+	container.Mounts = defaultMounts
+
 	for _, m := range c.Mounts {
 		dest, err := symlink.FollowSymlinkInScope(filepath.Join(c.Rootfs, m.Destination), c.Rootfs)
 		if err != nil {