diff --git a/components/cli/cli/compose/loader/volume.go b/components/cli/cli/compose/loader/volume.go index b026cf150f..9c2792e0f7 100644 --- a/components/cli/cli/compose/loader/volume.go +++ b/components/cli/cli/compose/loader/volume.go @@ -112,6 +112,11 @@ func isFilePath(source string) bool { return true } + // windows named pipes + if strings.HasPrefix(source, `\\`) { + return true + } + first, nextIndex := utf8.DecodeRuneInString(source) return isWindowsDrive([]rune{first}, rune(source[nextIndex])) } diff --git a/components/cli/cli/compose/loader/volume_test.go b/components/cli/cli/compose/loader/volume_test.go index 2f2e50a905..90110133fa 100644 --- a/components/cli/cli/compose/loader/volume_test.go +++ b/components/cli/cli/compose/loader/volume_test.go @@ -7,6 +7,7 @@ import ( "github.com/docker/cli/cli/compose/types" "github.com/docker/cli/internal/test/testutil" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestParseVolumeAnonymousVolume(t *testing.T) { @@ -149,6 +150,17 @@ func TestParseVolumeWithRW(t *testing.T) { } } +func TestParseVolumeWindowsNamedPipe(t *testing.T) { + volume, err := ParseVolume(`\\.\pipe\docker_engine:\\.\pipe\inside`) + require.NoError(t, err) + expected := types.ServiceVolumeConfig{ + Type: "bind", + Source: `\\.\pipe\docker_engine`, + Target: `\\.\pipe\inside`, + } + assert.Equal(t, expected, volume) +} + func TestIsFilePath(t *testing.T) { assert.False(t, isFilePath("a界")) }