public function testValidContainerName() { $container = new Container(); $container->setName('Foo/Bar'); $this->assertEquals('Foo/Bar', $container->getName()); }
/** * @param Container $container * * @return array */ private function getContainerHosts(Container $container) { $inspection = $container->getRuntimeInformations(); $hosts = [substr($container->getName(), 1) . $this->tld]; if (isset($inspection['Config']['Env']) && is_array($inspection['Config']['Env'])) { $env = $inspection['Config']['Env']; foreach (preg_grep('/DOMAIN_NAME=/', $env) as $row) { $row = substr($row, strlen('DOMAIN_NAME=')); $hosts = array_merge($hosts, explode(',', $row)); } } return $hosts; }
/** * Create a container (do not start it) * * @param \Docker\Container $container * * @throws \Docker\Exception\UnexpectedStatusCodeException * * @return \Docker\Manager\ContainerManager */ public function create(Container $container) { $response = $this->client->post(['/containers/create{?data*}', ['data' => ['name' => $container->getName()]]], ['body' => Json::encode($container->getConfig()), 'headers' => ['content-type' => 'application/json']]); if ($response->getStatusCode() !== "201") { throw UnexpectedStatusCodeException::fromResponse($response); } $container->setId($response->json()['Id']); return $this; }
/** * @return App\Model\Build */ public function setContainer(Container $container) { $this->container = $container; $this->setContainerId($container->getId()); $this->setContainerName($container->getName()); }