Docker\API\Model\ContainerConfig::setImage PHP Method

setImage() public method

public setImage ( string $image = null ) : self
$image string
return self
    public function setImage($image = null)
    {
        $this->image = $image;
        return $this;
    }

Usage Example

 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");
 }
All Usage Examples Of Docker\API\Model\ContainerConfig::setImage