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

Merge pull request #6735 from unclejack/add_test_pr-6701

Add test for PR 6701
This commit is contained in:
Michael Crosby 2014-06-27 11:05:18 -07:00
commit 3a50675a68
2 changed files with 13 additions and 1 deletions

View file

@ -971,3 +971,15 @@ func TestAllowBindMountingRoot(t *testing.T) {
logDone("run - bind mount / as volume")
}
func TestDisallowBindMountingRootToRoot(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-v", "/:/", "busybox", "ls", "/host")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
t.Fatal(out, err)
}
deleteAllContainers()
logDone("run - bind mount /:/ as volume should fail")
}

View file

@ -133,7 +133,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
for bind := range flVolumes.GetMap() {
if arr := strings.Split(bind, ":"); len(arr) > 1 {
if arr[1] == "/" {
return nil, nil, cmd, fmt.Errorf("Invalid bind mount: desination can't be '/'")
return nil, nil, cmd, fmt.Errorf("Invalid bind mount: destination can't be '/'")
}
// after creating the bind mount we want to delete it from the flVolumes values because
// we do not want bind mounts being committed to image configs