Browse code

Merge global storage options on create

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2017/08/15 03:00:10
Showing 1 changed files
... ...
@@ -137,6 +137,23 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) (
137 137
 
138 138
 	container.HostConfig.StorageOpt = params.HostConfig.StorageOpt
139 139
 
140
+	// Fixes: https://github.com/moby/moby/issues/34074 and
141
+	// https://github.com/docker/for-win/issues/999.
142
+	// Merge the daemon's storage options if they aren't already present. We only
143
+	// do this on Windows as there's no effective sandbox size limit other than
144
+	// physical on Linux.
145
+	if runtime.GOOS == "windows" {
146
+		if container.HostConfig.StorageOpt == nil {
147
+			container.HostConfig.StorageOpt = make(map[string]string)
148
+		}
149
+		for _, v := range daemon.configStore.GraphOptions {
150
+			opt := strings.SplitN(v, "=", 2)
151
+			if _, ok := container.HostConfig.StorageOpt[opt[0]]; !ok {
152
+				container.HostConfig.StorageOpt[opt[0]] = opt[1]
153
+			}
154
+		}
155
+	}
156
+
140 157
 	// Set RWLayer for container after mount labels have been set
141 158
 	if err := daemon.setRWLayer(container); err != nil {
142 159
 		return nil, err