|
@@ -109,3 +109,31 @@ func TestStartRecordError(t *testing.T) {
|
|
|
|
|
|
logDone("start - set state error when start fails")
|
|
logDone("start - set state error when start fails")
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// gh#8726: a failed Start() breaks --volumes-from on subsequent Start()'s
|
|
|
|
+func TestStartVolumesFromFailsCleanly(t *testing.T) {
|
|
|
|
+ defer deleteAllContainers()
|
|
|
|
+
|
|
|
|
+ // Create the first data volume
|
|
|
|
+ cmd(t, "run", "-d", "--name", "data_before", "-v", "/foo", "busybox")
|
|
|
|
+
|
|
|
|
+ // Expect this to fail because the data test after contaienr doesn't exist yet
|
|
|
|
+ if _, err := runCommand(exec.Command(dockerBinary, "run", "-d", "--name", "consumer", "--volumes-from", "data_before", "--volumes-from", "data_after", "busybox")); err == nil {
|
|
|
|
+ t.Fatal("Expected error but got none")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Create the second data volume
|
|
|
|
+ cmd(t, "run", "-d", "--name", "data_after", "-v", "/bar", "busybox")
|
|
|
|
+
|
|
|
|
+ // Now, all the volumes should be there
|
|
|
|
+ cmd(t, "start", "consumer")
|
|
|
|
+
|
|
|
|
+ // Check that we have the volumes we want
|
|
|
|
+ out, _, _ := cmd(t, "inspect", "--format='{{ len .Volumes }}'", "consumer")
|
|
|
|
+ n_volumes := strings.Trim(out, " \r\n'")
|
|
|
|
+ if n_volumes != "2" {
|
|
|
|
+ t.Fatalf("Missing volumes: expected 2, got %s", n_volumes)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ logDone("start - missing containers in --volumes-from did not affect subsequent runs")
|
|
|
|
+}
|