@@ -863,7 +863,7 @@ func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount
863
863
target := config .Target
864
864
if config .Target == "" {
865
865
target = configsBaseDir + config .Source
866
- } else if ! isUnixAbs (config .Target ) {
866
+ } else if ! isAbsTarget (config .Target ) {
867
867
target = configsBaseDir + config .Target
868
868
}
869
869
@@ -898,7 +898,7 @@ func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount
898
898
target := secret .Target
899
899
if secret .Target == "" {
900
900
target = secretsDir + secret .Source
901
- } else if ! isUnixAbs (secret .Target ) {
901
+ } else if ! isAbsTarget (secret .Target ) {
902
902
target = secretsDir + secret .Target
903
903
}
904
904
@@ -929,10 +929,24 @@ func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount
929
929
return values , nil
930
930
}
931
931
932
+ func isAbsTarget (p string ) bool {
933
+ return isUnixAbs (p ) || isWindowsAbs (p )
934
+ }
935
+
932
936
func isUnixAbs (p string ) bool {
933
937
return strings .HasPrefix (p , "/" )
934
938
}
935
939
940
+ func isWindowsAbs (p string ) bool {
941
+ if strings .HasPrefix (p , "\\ \\ " ) {
942
+ return true
943
+ }
944
+ if len (p ) > 2 && p [1 ] == ':' {
945
+ return p [2 ] == '\\'
946
+ }
947
+ return false
948
+ }
949
+
936
950
func buildMount (project types.Project , volume types.ServiceVolumeConfig ) (mount.Mount , error ) {
937
951
source := volume .Source
938
952
// on windows, filepath.IsAbs(source) is false for unix style abs path like /var/run/docker.sock.
0 commit comments