diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 094f9b9391..1c3d50437c 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -3501,7 +3501,9 @@ func (s *DockerCLIRunSuite) TestContainerWithConflictingNoneNetwork(c *testing.T // #11957 - stdin with no tty does not exit if stdin is not closed even though container exited func (s *DockerCLIRunSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) { - cmd := exec.Command(dockerBinary, "run", "-i", "--name=test", "busybox", "true") + name := "test-stdin-blocked-" + stringid.GenerateRandomID() + + cmd := exec.Command(dockerBinary, "run", "-i", "--name", name, "busybox", "true") in, err := cmd.StdinPipe() assert.NilError(c, err) defer in.Close() @@ -3509,14 +3511,23 @@ func (s *DockerCLIRunSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) cmd.Stdout = stdout cmd.Stderr = stdout assert.NilError(c, cmd.Start()) + c.Cleanup(func() { + dockerCmdWithError("rm", "-f", name) + }) - waitChan := make(chan error, 1) + exitTimeout := 10 * time.Second + if DaemonIsWindows() { + exitTimeout = 60 * time.Second + } + cli.WaitExited(c, name, exitTimeout) + + cmdExited := make(chan error, 1) go func() { - waitChan <- cmd.Wait() + cmdExited <- cmd.Wait() }() select { - case err := <-waitChan: + case err := <-cmdExited: assert.Assert(c, err == nil, stdout.String()) case <-time.After(30 * time.Second): c.Fatal("timeout waiting for command to exit")