Skip to content

Commit fe74f69

Browse files
committed
Fix absolute path handling for inherited volumes
Volumes keep unix-like absolute paths untouched, which was not the case for inherited volumes from extended services. Fix this by using the same method, which is used by standard volume path resolution. Signed-off-by: Oldřich Jedlička <[email protected]>
1 parent f4cd055 commit fe74f69

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
556556
if vol.Type != types.VolumeTypeBind {
557557
continue
558558
}
559-
baseService.Volumes[i].Source = absPath(baseFileParent, vol.Source)
559+
baseService.Volumes[i].Source = resolveMaybeUnixPath(vol.Source, baseFileParent, lookupEnv)
560560
}
561561
}
562562

loader/loader_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,12 @@ func TestLoadWithExtends(t *testing.T) {
18341834
},
18351835
Environment: types.MappingWithEquals{},
18361836
Networks: map[string]*types.ServiceNetworkConfig{"default": nil},
1837+
Volumes: []types.ServiceVolumeConfig{{
1838+
Type: "bind",
1839+
Source: "/opt/data",
1840+
Target: "/var/lib/mysql",
1841+
Bind: &types.ServiceVolumeBind{CreateHostPath: true},
1842+
}},
18371843
Scale: 1,
18381844
},
18391845
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
services:
22
imported:
33
image: nginx
4+
volumes:
5+
- /opt/data:/var/lib/mysql

0 commit comments

Comments
 (0)