1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Force abs paths for host volumes

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-03-31 19:10:19 +00:00
parent 1805ef1ccc
commit 904bf049c1
2 changed files with 19 additions and 0 deletions

View file

@ -271,3 +271,15 @@ func TestDockerRunWithVolumesAsFiles(t *testing.T) {
logDone("run - regression test for #4741 - volumes from as files")
}
// Regression test for #4830
func TestDockerRunWithRelativePath(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "-v", "tmp:/other-tmp", "busybox", "true")
if _, _, _, err := runCommandWithStdoutStderr(runCmd); err == nil {
t.Fatalf("relative path should result in an error")
}
deleteAllContainers()
logDone("run - volume with relative path")
}

View file

@ -172,6 +172,13 @@ func createVolumes(container *Container) error {
if bindMap, exists := binds[volPath]; exists {
isBindMount = true
srcPath = bindMap.SrcPath
srcAbs, err := filepath.Abs(srcPath)
if err != nil {
return err
}
if srcPath != srcAbs {
return fmt.Errorf("%s should be an absolute path", srcPath)
}
if strings.ToLower(bindMap.Mode) == "rw" {
srcRW = true
}