/** * 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; }