Skip to content

Commit 6e35652

Browse files
ndeloofglours
authored andcommitted
fix support for remote absolute path
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 5bb4603 commit 6e35652

3 files changed

Lines changed: 15 additions & 20 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/Microsoft/go-winio v0.6.2
99
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
1010
github.com/buger/goterm v1.0.4
11-
github.com/compose-spec/compose-go/v2 v2.6.2-0.20250423090706-30ff01d36f76
11+
github.com/compose-spec/compose-go/v2 v2.6.2-0.20250428082045-7eb3472a5a95
1212
github.com/containerd/containerd/v2 v2.0.5
1313
github.com/containerd/platforms v1.0.0-rc.1
1414
github.com/davecgh/go-spew v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e
8282
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA=
8383
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
8484
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4=
85-
github.com/compose-spec/compose-go/v2 v2.6.2-0.20250423090706-30ff01d36f76 h1:KZvD41eTRr9/n43zccAcGPBRgzHXdbLZY4IXSeJxqIw=
86-
github.com/compose-spec/compose-go/v2 v2.6.2-0.20250423090706-30ff01d36f76/go.mod h1:vPlkN0i+0LjLf9rv52lodNMUTJF5YHVfHVGLLIP67NA=
85+
github.com/compose-spec/compose-go/v2 v2.6.2-0.20250428082045-7eb3472a5a95 h1:lWMFXVkl+LkMdllYT4P/5snsB8JNhQoFnSsRX1pbX1o=
86+
github.com/compose-spec/compose-go/v2 v2.6.2-0.20250428082045-7eb3472a5a95/go.mod h1:vPlkN0i+0LjLf9rv52lodNMUTJF5YHVfHVGLLIP67NA=
8787
github.com/containerd/cgroups/v3 v3.0.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJHo6Bzo=
8888
github.com/containerd/cgroups/v3 v3.0.5/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins=
8989
github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro=

pkg/compose/create.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"strconv"
2828
"strings"
2929

30+
"github.com/compose-spec/compose-go/v2/paths"
3031
"github.com/compose-spec/compose-go/v2/types"
3132
"github.com/docker/compose/v2/pkg/api"
3233
"github.com/docker/compose/v2/pkg/progress"
@@ -1126,28 +1127,22 @@ func isUnixAbs(p string) bool {
11261127
}
11271128

11281129
func isWindowsAbs(p string) bool {
1129-
if strings.HasPrefix(p, "\\\\") {
1130-
return true
1131-
}
1132-
if len(p) > 2 && p[1] == ':' {
1133-
return p[2] == '\\'
1134-
}
1135-
return false
1130+
return paths.IsWindowsAbs(p)
11361131
}
11371132

11381133
func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.Mount, error) {
11391134
source := volume.Source
1140-
// on windows, filepath.IsAbs(source) is false for unix style abs path like /var/run/docker.sock.
1141-
// do not replace these with filepath.Abs(source) that will include a default drive.
1142-
if volume.Type == types.VolumeTypeBind && !filepath.IsAbs(source) && !strings.HasPrefix(source, "/") {
1143-
// volume source has already been prefixed with workdir if required, by compose-go project loader
1144-
var err error
1145-
source, err = filepath.Abs(source)
1146-
if err != nil {
1147-
return mount.Mount{}, err
1135+
switch volume.Type {
1136+
case types.VolumeTypeBind:
1137+
if !filepath.IsAbs(source) && !isUnixAbs(source) && !isWindowsAbs(source) {
1138+
// volume source has already been prefixed with workdir if required, by compose-go project loader
1139+
var err error
1140+
source, err = filepath.Abs(source)
1141+
if err != nil {
1142+
return mount.Mount{}, err
1143+
}
11481144
}
1149-
}
1150-
if volume.Type == types.VolumeTypeVolume {
1145+
case types.VolumeTypeVolume:
11511146
if volume.Source != "" {
11521147
pVolume, ok := project.Volumes[volume.Source]
11531148
if ok {

0 commit comments

Comments
 (0)