Skip to content

Commit

Permalink
Volume mounts need to use "Binds" API field
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cpuguy83 committed Jun 30, 2016
1 parent e82dcf1 commit 2bc2165
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions daemon/cluster/executor/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ func (c *containerConfig) image() string {
func (c *containerConfig) volumes() map[string]struct{} {
r := make(map[string]struct{})

for _, mount := range c.spec().Mounts {
for _, m := range c.spec().Mounts {
// pick off all the volume mounts.
if mount.Type != api.MountTypeVolume {
if m.Type != api.MountTypeVolume || m.Source != "" {
continue
}

r[fmt.Sprintf("%s:%s", mount.Target, getMountMask(&mount))] = struct{}{}
r[m.Target] = struct{}{}
}

return r
Expand Down Expand Up @@ -165,7 +164,7 @@ func (c *containerConfig) bindMounts() []string {

for _, val := range c.spec().Mounts {
mask := getMountMask(&val)
if val.Type == api.MountTypeBind {
if val.Type == api.MountTypeBind || (val.Type == api.MountTypeVolume && val.Source != "") {
r = append(r, fmt.Sprintf("%s:%s:%s", val.Source, val.Target, mask))
}
}
Expand Down

0 comments on commit 2bc2165

Please sign in to comment.