示例#1
0
 /**
  * Get history of an image
  *
  * @param Image $image
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  *
  * @return array
  */
 public function history(Image $image)
 {
     $response = $this->client->get(['/images/{name}/history', ['name' => $image->__toString()]]);
     if ($response->getStatusCode() !== "200") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     return $response->json();
 }
 /**
  * Rename a container (API v1.17)
  *
  * @param Container $container
  * @param string $newname
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  */
 public function rename(Container $container, $newname)
 {
     $response = $this->client->post(['/containers/{id}/rename?name={newname}', ['id' => $container->getId(), 'newname' => $newname]]);
     if ($response->getStatusCode() !== "204") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     return $this;
 }
 /**
  * Unpause a container
  *
  * @param Container $container
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  */
 public function unpause(Container $container)
 {
     $response = $this->client->post(['/containers/{id}/unpause', ['id' => $container->getId()]]);
     if ($response->getStatusCode() !== "204") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     $this->inspect($container);
     return $this;
 }
示例#4
0
 /**
  * Delete a container from docker server
  *
  * @param \Docker\Container  $container
  * @param boolean           $volumes
  *
  * @return \Docker\Manager\ContainerManager
  */
 public function remove(Container $container, $volumes = false)
 {
     $response = $this->client->delete(['/containers/{id}?v={volumes}', ['id' => $container->getId(), 'v' => $volumes]]);
     if ($response->getStatusCode() !== "204") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     return $this;
 }
示例#5
0
 /**
  * Delete an image from docker daemon
  *
  * @param Image   $image   Image to delete
  * @param boolean $force   Force deletion of image (default false)
  * @param boolean $noprune Do not delete parent images (default false)
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  *
  * @return ImageManager
  */
 public function delete(Image $image, $force = false, $noprune = false)
 {
     $response = $this->client->delete(['/images/{image}?force={force}&noprune={noprune}', ['image' => $image->__toString(), 'force' => $force, 'noprune' => $noprune, 'wait' => true]]);
     if ($response->getStatusCode() !== "200") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     return $this;
 }
示例#6
0
 /**
  * Send a signal to container
  *
  * @param Container $container
  * @param string $signal
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  */
 public function kill(Container $container, $signal = "SIGKILL")
 {
     $response = $this->client->post(['/containers/{id}/kill?signal={signal}', ['id' => $container->getId(), 'signal' => $signal]]);
     if ($response->getStatusCode() !== "204") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
 }