Browse code

Filter out default mounts that are override by user.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Mrunal Patel authored on 2015/03/13 06:59:57
Showing 1 changed files
... ...
@@ -212,6 +212,20 @@ func (d *driver) setupRlimits(container *configs.Config, c *execdriver.Command)
212 212
 }
213 213
 
214 214
 func (d *driver) setupMounts(container *configs.Config, c *execdriver.Command) error {
215
+	userMounts := make(map[string]struct{})
216
+	for _, m := range c.Mounts {
217
+		userMounts[m.Destination] = struct{}{}
218
+	}
219
+
220
+	// Filter out mounts that are overriden by user supplied mounts
221
+	var defaultMounts []*configs.Mount
222
+	for _, m := range container.Mounts {
223
+		if _, ok := userMounts[m.Destination]; !ok {
224
+			defaultMounts = append(defaultMounts, m)
225
+		}
226
+	}
227
+	container.Mounts = defaultMounts
228
+
215 229
 	for _, m := range c.Mounts {
216 230
 		dest, err := symlink.FollowSymlinkInScope(filepath.Join(c.Rootfs, m.Destination), c.Rootfs)
217 231
 		if err != nil {