From 461b5cf48597675208e6f1cf0b5fcd05d0354133 Mon Sep 17 00:00:00 2001 From: Bryce Palmer Date: Sun, 27 Feb 2022 17:21:03 -0500 Subject: [PATCH] fix issue with docker volume on windows --- utils/docker.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/utils/docker.go b/utils/docker.go index d871d8e..a177cfb 100644 --- a/utils/docker.go +++ b/utils/docker.go @@ -139,22 +139,30 @@ func (u *Utility) RunContainer(image string, ports []string, volumes []string, c // add the volumes to the command for _, vol := range volumes { + // Define variables needed for volume parsing + var source string + var target string + var options string + + // If the host is a windows machine we need to remove the 'C:' and add it again later + if runtime.GOOS == "windows" { + vol = strings.TrimLeft(vol, "c:") + source += "C:" + } + if vErr := u.validateRunContainerVolume(vol); vErr != nil { return "", vErr } splitVol := strings.Split(vol, ":") - var source string - var target string - var options string if len(splitVol) == 3 { - source = splitVol[0] - target = splitVol[1] - options = ":" + splitVol[2] + source += splitVol[0] + target += splitVol[1] + options += ":" + splitVol[2] } else { - source = splitVol[0] - target = splitVol[1] + source += splitVol[0] + target += splitVol[1] } source, err := filepath.Abs(source)