Skip to content

Commit

Permalink
Merge pull request #332 from ndeloof/driver_opts
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeloof committed Dec 24, 2022
2 parents 4c5c833 + 3903f95 commit 06f2fe3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions loader/loader_test.go
Expand Up @@ -2131,3 +2131,26 @@ services:
assert.Equal(t, "env-var-web", svc.ContainerName)
})
}

func TestLoadWithBindMountVolume(t *testing.T) {
dict := `
services:
web:
image: web
volumes:
- data:/data
volumes:
data:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: './data'
`
configDetails := buildConfigDetails(dict, nil)

project, err := Load(configDetails)
assert.NilError(t, err)
path := project.Volumes["data"].DriverOpts["device"]
assert.Check(t, filepath.IsAbs(path))
}
8 changes: 8 additions & 0 deletions loader/normalize.go
Expand Up @@ -110,6 +110,14 @@ func normalize(project *types.Project, resolvePaths bool) error {
project.Services[i] = s
}

for name, config := range project.Volumes {
if config.Driver == "local" && config.DriverOpts["o"] == "bind" {
// This is actually a bind mount
config.DriverOpts["device"] = absPath(project.WorkingDir, config.DriverOpts["device"])
project.Volumes[name] = config
}
}

setNameFromKey(project)

return nil
Expand Down

0 comments on commit 06f2fe3

Please sign in to comment.