public setAttachStdin ( boolean $attachStdin = null ) : self | ||
$attachStdin | boolean | |
return | self |
public function testAttachWebsocket() { $containerConfig = new ContainerConfig(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['sh']); $containerConfig->setAttachStdout(true); $containerConfig->setAttachStderr(true); $containerConfig->setAttachStdin(false); $containerConfig->setOpenStdin(true); $containerConfig->setTty(true); $containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true'])); $containerCreateResult = $this->getManager()->create($containerConfig); $webSocketStream = $this->getManager()->attachWebsocket($containerCreateResult->getId(), ['stream' => true, 'stdout' => true, 'stderr' => true, 'stdin' => true]); $this->getManager()->start($containerCreateResult->getId()); // Read the bash first line $webSocketStream->read(); // No output after that so it should be false $this->assertFalse($webSocketStream->read()); // Write something to the container $webSocketStream->write("echo test\n"); // Test for echo present (stdin) $output = ""; while (($data = $webSocketStream->read()) != false) { $output .= $data; } $this->assertContains("echo", $output); // Exit the container $webSocketStream->write("exit\n"); }