Browse Source

Merge pull request #6735 from unclejack/add_test_pr-6701

Add test for PR 6701
Michael Crosby 11 years ago
parent
commit
3a50675a68
2 changed files with 13 additions and 1 deletions
  1. 12 0
      integration-cli/docker_cli_run_test.go
  2. 1 1
      runconfig/parse.go

+ 12 - 0
integration-cli/docker_cli_run_test.go

@@ -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")
+}

+ 1 - 1
runconfig/parse.go

@@ -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