Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 84fcdee

Browse files
authored
Merge pull request #1497 from docker/windows_mount
don't use filepath to process remote bind paths
2 parents bd5c188 + dc036c2 commit 84fcdee

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

local/compose/create.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount
618618
for _, config := range s.Configs {
619619
target := config.Target
620620
if config.Target == "" {
621-
target = filepath.Join(configsBaseDir, config.Source)
622-
} else if !filepath.IsAbs(config.Target) {
623-
target = filepath.Join(configsBaseDir, config.Target)
621+
target = configsBaseDir + config.Source
622+
} else if !isUnixAbs(config.Target) {
623+
target = configsBaseDir + config.Target
624624
}
625625

626626
definedConfig := p.Configs[config.Source]
@@ -649,13 +649,13 @@ func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount
649649
func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) {
650650
var mounts = map[string]mount.Mount{}
651651

652-
secretsDir := "/run/secrets"
652+
secretsDir := "/run/secrets/"
653653
for _, secret := range s.Secrets {
654654
target := secret.Target
655655
if secret.Target == "" {
656-
target = filepath.Join(secretsDir, secret.Source)
657-
} else if !filepath.IsAbs(secret.Target) {
658-
target = filepath.Join(secretsDir, secret.Target)
656+
target = secretsDir + secret.Source
657+
} else if !isUnixAbs(secret.Target) {
658+
target = secretsDir + secret.Target
659659
}
660660

661661
definedSecret := p.Secrets[secret.Source]
@@ -681,6 +681,10 @@ func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount
681681
return values, nil
682682
}
683683

684+
func isUnixAbs(path string) bool {
685+
return strings.HasPrefix(path, "/")
686+
}
687+
684688
func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.Mount, error) {
685689
source := volume.Source
686690
if volume.Type == types.VolumeTypeBind && !filepath.IsAbs(source) {
@@ -699,7 +703,6 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
699703
source = pVolume.Name
700704
}
701705
}
702-
703706
}
704707

705708
return mount.Mount{

0 commit comments

Comments
 (0)