Ejemplo n.º 1
0
 /**
  * Start an executive defined from exec()
  * This can be resude several times, so if the command /bin/date in defined in exec()
  * execstart() on that ID will return a different value each time.
  * todo: how are instances created by exec() and used by execstart() removed/cleanedup?
  *
  * @param string   $execid       identifier from exec()
  * @param callable $callback
  * @param boolean  $detach
  * @param boolean  $tty
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  *
  * @return \GuzzleHttp\Message\ResponseInterface
  */
 public function execstart($execid, callable $callback = null, $detach = false, $tty = false)
 {
     $body = ['Detach' => $detach, 'Tty' => $tty];
     $callback = $callback === null ? function () {
     } : $callback;
     $response = $this->client->post(['/exec/{id}/start', ['id' => $execid]], ['body' => Json::encode($body), 'headers' => ['content-type' => 'application/json'], 'callback' => $callback]);
     if ($response->getStatusCode() !== "200") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * @param \Docker\Container $container
  * @param array             $hostConfig     Config when starting the container (for port binding e.g.)
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  *
  * @return \Docker\Manager\ContainerManager
  */
 public function start(Container $container, array $hostConfig = array())
 {
     $response = $this->client->post(['/containers/{id}/start', ['id' => $container->getId()]], array('body' => Json::encode($hostConfig), 'headers' => array('content-type' => 'application/json')));
     if ($response->getStatusCode() !== "204") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     $this->inspect($container);
     return $this;
 }