diff --git a/test/docker/docker_api_test_util.go b/test/docker/docker_api_test_util.go index 7c54b3e..5409b45 100644 --- a/test/docker/docker_api_test_util.go +++ b/test/docker/docker_api_test_util.go @@ -309,13 +309,23 @@ func execContainerWithOutput(t *testing.T, cli *client.Client, ID string, user s if err != nil { t.Fatal(err) } - cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{ + err = cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{ Detach: false, Tty: false, }) if err != nil { t.Fatal(err) } + // Wait for the command to finish + for { + inspect, err := cli.ContainerExecInspect(context.Background(), resp.ID) + if err != nil { + t.Fatal(err) + } + if !inspect.Running { + break + } + } buf := new(bytes.Buffer) // Each output line has a header, which needs to be removed _, err = stdcopy.StdCopy(buf, buf, hijack.Reader)