コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: Docker.php プロジェクト: schmunk42/docker-php
 /**
  * Commit a container into an image
  *
  * @param \Docker\Container $container
  * @param array             $config
  *
  * @throws Exception\UnexpectedStatusCodeException
  *
  * @return \Docker\Image
  *
  * @see http://docs.docker.com/reference/api/docker_remote_api_v1.7/#create-a-new-image-from-a-containers-changes
  */
 public function commit(Container $container, $config = [])
 {
     if (isset($config['run'])) {
         $config['run'] = json_encode($config['run']);
     }
     $config['container'] = $container->getId();
     $response = $this->httpClient->post(['/commit{?config*}', ['config' => $config]]);
     if ($response->getStatusCode() !== "201") {
         throw new UnexpectedStatusCodeException($response->getStatusCode(), (string) $response->getBody());
     }
     $image = new Image();
     $image->setId($response->json()['Id']);
     if (array_key_exists('repo', $config)) {
         $image->setRepository($config['repo']);
     }
     if (array_key_exists('tag', $config)) {
         $image->setTag($config['tag']);
     }
     return $image;
 }
コード例 #4
0
ファイル: Build.php プロジェクト: blazarecki/stage1
 /**
  * @return App\Model\Build
  */
 public function setContainer(Container $container)
 {
     $this->container = $container;
     $this->setContainerId($container->getId());
     $this->setContainerName($container->getName());
 }
コード例 #5
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;
 }
コード例 #6
0
ファイル: ContainerManager.php プロジェクト: XDocker/app
 /**
  * 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);
     }
 }