Skip to content

Commit

Permalink
Merge pull request moby#4929 from crosbymichael/volume-abs-path
Browse files Browse the repository at this point in the history
Force abs paths for host volumes
  • Loading branch information
creack committed Mar 31, 2014
2 parents e76113b + 904bf04 commit f6f059d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions integration-cli/docker_cli_run_test.go
Expand Up @@ -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")
}
7 changes: 7 additions & 0 deletions runtime/volumes.go
Expand Up @@ -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
}
Expand Down

0 comments on commit f6f059d

Please sign in to comment.