From 855dc5ba79f75fc0f13e8a26b670de99fc101ab5 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Fri, 24 Jun 2016 16:17:37 -0400 Subject: [PATCH] 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 (cherry picked from commit 2bc2165cbf3e949921d1659f09841b5f008f590d) Signed-off-by: Tibor Vass --- daemon/cluster/executor/container/container.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index 36a8cb246f..ece2ec3743 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -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 @@ -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)) } }