Skip to content

Commit

Permalink
Merge pull request #136 from johnstep/fix_stack_service_volumes
Browse files Browse the repository at this point in the history
Fix stack compose bind-mount volumes for Windows
  • Loading branch information
cpuguy83 committed Jun 1, 2017
2 parents efaadcf + 9043d39 commit bf22fc6
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cli/compose/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package loader
import (
"fmt"
"path"
"path/filepath"
"reflect"
"sort"
"strings"
Expand Down Expand Up @@ -371,7 +372,16 @@ func resolveVolumePaths(volumes []types.ServiceVolumeConfig, workingDir string,
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
}
}
Expand Down Expand Up @@ -492,11 +502,11 @@ func LoadConfigObjs(source map[string]interface{}, workingDir string) (map[strin
return configs, nil
}

func absPath(workingDir string, filepath string) string {
if path.IsAbs(filepath) {
return filepath
func absPath(workingDir string, filePath string) string {
if filepath.IsAbs(filePath) {
return filePath
}
return path.Join(workingDir, filepath)
return filepath.Join(workingDir, filePath)
}

func transformMapStringString(data interface{}) (interface{}, error) {
Expand Down

0 comments on commit bf22fc6

Please sign in to comment.