소스 검색

Merge pull request #8392 from jfrazelle/pr_8389

Invalid mount mode for volumes in
Andrea Luzzardi 10 년 전
부모
커밋
84d9fd37b0
2개의 변경된 파일13개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      daemon/volumes.go
  2. 12 2
      integration-cli/docker_cli_run_test.go

+ 1 - 1
daemon/volumes.go

@@ -235,7 +235,7 @@ func parseVolumesFromSpec(daemon *Daemon, spec string) (map[string]*Mount, error
 
 	if len(specParts) == 2 {
 		mode := specParts[1]
-		if validMountMode(mode) {
+		if !validMountMode(mode) {
 			return nil, fmt.Errorf("Invalid mode for volumes-from: %s", mode)
 		}
 

+ 12 - 2
integration-cli/docker_cli_run_test.go

@@ -389,9 +389,19 @@ func TestRunVolumesFromInReadWriteMode(t *testing.T) {
 		t.Fatal(err)
 	}
 
+	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:rw", "busybox", "touch", "/test/file")
+	if out, _, err := runCommandWithOutput(cmd); err != nil {
+		t.Fatalf("running --volumes-from parent:rw failed with output: %q\nerror: %v", out, err)
+	}
+
+	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent:bar", "busybox", "touch", "/test/file")
+	if out, _, err := runCommandWithOutput(cmd); err == nil || !strings.Contains(out, "Invalid mode for volumes-from: bar") {
+		t.Fatalf("running --volumes-from foo:bar should have failed with invalid mount mode: %q", out)
+	}
+
 	cmd = exec.Command(dockerBinary, "run", "--volumes-from", "parent", "busybox", "touch", "/test/file")
-	if _, err := runCommand(cmd); err != nil {
-		t.Fatal(err)
+	if out, _, err := runCommandWithOutput(cmd); err != nil {
+		t.Fatalf("running --volumes-from parent failed with output: %q\nerror: %v", out, err)
 	}
 
 	deleteAllContainers()