diff --git a/drivers/docker/utils.go b/drivers/docker/utils.go index 81e9e06cb..5692a54b6 100644 --- a/drivers/docker/utils.go +++ b/drivers/docker/utils.go @@ -6,6 +6,8 @@ import ( "os" "os/exec" "path/filepath" + "regexp" + "runtime" "strings" "github.com/docker/cli/cli/config/configfile" @@ -206,6 +208,16 @@ func validateCgroupPermission(s string) bool { // expandPath returns the absolute path of dir, relative to base if dir is relative path. // base is expected to be an absolute path func expandPath(base, dir string) string { + if runtime.GOOS == "windows" { + pipeExp := regexp.MustCompile(`^` + rxPipe + `$`) + match := pipeExp.FindStringSubmatch(strings.ToLower(dir)) + + if len(match) == 1 { + // avoid resolving dot-segment in named pipe + return dir + } + } + if filepath.IsAbs(dir) { return filepath.Clean(dir) } diff --git a/drivers/docker/utils_windows_test.go b/drivers/docker/utils_windows_test.go index ebc0350be..2891fe8d3 100644 --- a/drivers/docker/utils_windows_test.go +++ b/drivers/docker/utils_windows_test.go @@ -24,6 +24,8 @@ func TestExpandPath(t *testing.T) { {"/tmp/alloc/task", "c:/home/user", "c:/home/user"}, {"/tmp/alloc/task", "c:/home/user/..", "c:/home"}, + + {"/tmp/alloc/task", `//./pipe/named_pipe`, `//./pipe/named_pipe`}, } for _, c := range cases { @@ -55,6 +57,13 @@ func TestParseVolumeSpec_Windows(t *testing.T) { `e:\containerpath`, "", }, + { + "named pipe", + `//./pipe/named_pipe://./pipe/named_pipe`, + `\\.\pipe\named_pipe`, + `//./pipe/named_pipe`, + "", + }, } for _, c := range validCases {