Fix stack compose bind-mount volumes for Windows

For stack compose files, use filepath.IsAbs instead of path.IsAbs, for
bind-mounted service volumes, because filepath.IsAbs handles Windows
paths, while path.IsAbs does not.

Signed-off-by: John Stephens <johnstep@docker.com>
This commit is contained in:
John Stephens 2017-05-27 12:29:30 -07:00
parent 6c59636498
commit 9043d39dea
No known key found for this signature in database
GPG Key ID: 240549B2101E94D4
1 changed files with 15 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package loader
import ( import (
"fmt" "fmt"
"path" "path"
"path/filepath"
"reflect" "reflect"
"sort" "sort"
"strings" "strings"
@ -371,7 +372,16 @@ func resolveVolumePaths(volumes []types.ServiceVolumeConfig, workingDir string,
continue continue
} }
volume.Source = absPath(workingDir, expandUser(volume.Source, lookupEnv)) filePath := expandUser(volume.Source, lookupEnv)
// Check for a Unix absolute path first, to handle a Windows client
// with a Unix daemon. This handles a Windows client connecting to a
// Unix daemon. Note that this is not required for Docker for Windows
// when specifying a local Windows path, because Docker for Windows
// translates the Windows path into a valid path within the VM.
if !path.IsAbs(filePath) {
filePath = absPath(workingDir, filePath)
}
volume.Source = filePath
volumes[i] = volume volumes[i] = volume
} }
} }
@ -492,11 +502,11 @@ func LoadConfigObjs(source map[string]interface{}, workingDir string) (map[strin
return configs, nil return configs, nil
} }
func absPath(workingDir string, filepath string) string { func absPath(workingDir string, filePath string) string {
if path.IsAbs(filepath) { if filepath.IsAbs(filePath) {
return filepath return filePath
} }
return path.Join(workingDir, filepath) return filepath.Join(workingDir, filePath)
} }
func transformMapStringString(data interface{}) (interface{}, error) { func transformMapStringString(data interface{}) (interface{}, error) {