@@ -563,7 +563,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
563563 if vol .Type != types .VolumeTypeBind {
564564 continue
565565 }
566- baseService .Volumes [i ].Source = absPath ( baseFileParent , vol .Source )
566+ baseService .Volumes [i ].Source = resolveMaybeUnixPath ( vol .Source , baseFileParent , lookupEnv )
567567 }
568568 }
569569
@@ -667,8 +667,8 @@ func resolveEnvironment(serviceConfig *types.ServiceConfig, workingDir string, l
667667 return nil
668668}
669669
670- func resolveVolumePath ( volume types. ServiceVolumeConfig , workingDir string , lookupEnv template.Mapping ) types. ServiceVolumeConfig {
671- filePath := expandUser (volume . Source , lookupEnv )
670+ func resolveMaybeUnixPath ( path string , workingDir string , lookupEnv template.Mapping ) string {
671+ filePath := expandUser (path , lookupEnv )
672672 // Check if source is an absolute path (either Unix or Windows), to
673673 // handle a Windows client with a Unix daemon or vice-versa.
674674 //
@@ -678,10 +678,21 @@ func resolveVolumePath(volume types.ServiceVolumeConfig, workingDir string, look
678678 if ! paths .IsAbs (filePath ) && ! isAbs (filePath ) {
679679 filePath = absPath (workingDir , filePath )
680680 }
681- volume .Source = filePath
681+ return filePath
682+ }
683+
684+ func resolveVolumePath (volume types.ServiceVolumeConfig , workingDir string , lookupEnv template.Mapping ) types.ServiceVolumeConfig {
685+ volume .Source = resolveMaybeUnixPath (volume .Source , workingDir , lookupEnv )
682686 return volume
683687}
684688
689+ func resolveSecretsPath (secret types.SecretConfig , workingDir string , lookupEnv template.Mapping ) types.SecretConfig {
690+ if ! secret .External .External && secret .File != "" {
691+ secret .File = resolveMaybeUnixPath (secret .File , workingDir , lookupEnv )
692+ }
693+ return secret
694+ }
695+
685696// TODO: make this more robust
686697func expandUser (path string , lookupEnv template.Mapping ) string {
687698 if strings .HasPrefix (path , "~" ) {
@@ -789,11 +800,14 @@ func LoadSecrets(source map[string]interface{}, details types.ConfigDetails, res
789800 return secrets , err
790801 }
791802 for name , secret := range secrets {
792- obj , err := loadFileObjectConfig (name , "secret" , types .FileObjectConfig (secret ), details , resolvePaths )
803+ obj , err := loadFileObjectConfig (name , "secret" , types .FileObjectConfig (secret ), details , false )
793804 if err != nil {
794805 return nil , err
795806 }
796807 secretConfig := types .SecretConfig (obj )
808+ if resolvePaths {
809+ secretConfig = resolveSecretsPath (secretConfig , details .WorkingDir , details .LookupEnv )
810+ }
797811 secrets [name ] = secretConfig
798812 }
799813 return secrets , nil
0 commit comments