Example #1
0
 public function testExecFind()
 {
     $createContainerResult = $this->createContainer();
     $execConfig = new ExecConfig();
     $execConfig->setCmd(["/bin/true"]);
     $execCreateResult = $this->getManager()->create($createContainerResult->getId(), $execConfig);
     $execStartConfig = new ExecStartConfig();
     $execStartConfig->setDetach(false);
     $execStartConfig->setTty(false);
     $this->getManager()->start($execCreateResult->getId(), $execStartConfig);
     $execFindResult = $this->getManager()->find($execCreateResult->getId());
     $this->assertInstanceOf('Docker\\API\\Model\\ExecCommand', $execFindResult);
     self::getDocker()->getContainerManager()->kill($createContainerResult->getId(), ['signal' => 'SIGKILL']);
 }
 public function testStartStream()
 {
     $createContainerResult = $this->createContainer();
     $execConfig = new ExecConfig();
     $execConfig->setAttachStdout(true);
     $execConfig->setAttachStderr(true);
     $execConfig->setCmd(["echo", "output"]);
     $execCreateResult = $this->getManager()->create($createContainerResult->getId(), $execConfig);
     $execStartConfig = new ExecStartConfig();
     $execStartConfig->setDetach(false);
     $execStartConfig->setTty(false);
     $stream = $this->getManager()->start($execCreateResult->getId(), $execStartConfig, [], ExecManager::FETCH_STREAM);
     $this->assertInstanceOf('Docker\\Stream\\DockerRawStream', $stream);
     $stdoutFull = "";
     $stream->onStdout(function ($stdout) use(&$stdoutFull) {
         $stdoutFull .= $stdout;
     });
     $stream->wait();
     $this->assertEquals("output\n", $stdoutFull);
     self::getDocker()->getContainerManager()->kill($createContainerResult->getId(), ['signal' => 'SIGKILL']);
 }