Skip to content

Commit

Permalink
fix: Windows<->Linux path conversion when using remote host
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 committed Jan 12, 2024
1 parent fbee838 commit 7314916
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/driver/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ func (d *dockerDriver) RunDockerDevContainer(

// workspace mount
if options.WorkspaceMount != nil {
args = append(args, "--mount", options.WorkspaceMount.String())
workspacePath := d.EnsurePath(options.WorkspaceMount)

args = append(args, "--mount", workspacePath.String())
}

// override container user
Expand Down Expand Up @@ -316,3 +318,25 @@ func (d *dockerDriver) RunDockerDevContainer(

return nil
}

func (d *dockerDriver) EnsurePath(path *config.Mount) *config.Mount {
// in case of local windows and remote linux tcp, we need to manually do the path conversion
if runtime.GOOS == "windows" {
for _, v := range d.Docker.Environment {
// we do this only is DOCKER_HOST is not docker-desktop engine, but
// a direct TCP connection to a docker daemon running in WSL
if strings.Contains(v, "DOCKER_HOST=tcp://") {

unixPath := path.Source
unixPath = strings.Replace(unixPath, "C:", "c", 1)
unixPath = strings.ReplaceAll(unixPath, "\\", "/")
unixPath = "/mnt/" + unixPath

path.Source = unixPath

return path
}
}
}
return path
}

0 comments on commit 7314916

Please sign in to comment.