Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve device path for local bind mount volumes #332

Merged
merged 1 commit into from Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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