Browse code

Volume mounts need to use "Binds" API field

Swarm was putting volume type mounts into the container config's
"Volumes" field, but really these need to go into "Binds".
"Volumes" is only for normal "-v /foo" volumes, not named volumes or
anything else.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 2bc2165cbf3e949921d1659f09841b5f008f590d)
Signed-off-by: Tibor Vass <tibor@docker.com>

Brian Goff authored on 2016/06/25 05:17:37
Showing 1 changed files
... ...
@@ -91,13 +91,12 @@ func (c *containerConfig) image() string {
91 91
 func (c *containerConfig) volumes() map[string]struct{} {
92 92
 	r := make(map[string]struct{})
93 93
 
94
-	for _, mount := range c.spec().Mounts {
94
+	for _, m := range c.spec().Mounts {
95 95
 		// pick off all the volume mounts.
96
-		if mount.Type != api.MountTypeVolume {
96
+		if m.Type != api.MountTypeVolume || m.Source != "" {
97 97
 			continue
98 98
 		}
99
-
100
-		r[fmt.Sprintf("%s:%s", mount.Target, getMountMask(&mount))] = struct{}{}
99
+		r[m.Target] = struct{}{}
101 100
 	}
102 101
 
103 102
 	return r
... ...
@@ -165,7 +164,7 @@ func (c *containerConfig) bindMounts() []string {
165 165
 
166 166
 	for _, val := range c.spec().Mounts {
167 167
 		mask := getMountMask(&val)
168
-		if val.Type == api.MountTypeBind {
168
+		if val.Type == api.MountTypeBind || (val.Type == api.MountTypeVolume && val.Source != "") {
169 169
 			r = append(r, fmt.Sprintf("%s:%s:%s", val.Source, val.Target, mask))
170 170
 		}
171 171
 	}