src/Joli/JoliCi/ServiceManager.php
public function start(Job $build)
    {
        foreach ($build->getServices() as $service) {
            try {
                $this->docker->getImageManager()->find(sprintf('%s:%s', $service->getRepository(), $service->getTag()));
            } catch (ClientErrorException $e) {
                if ($e->getResponse()->getStatusCode() == 404) {
                    $buildStream = $this->docker->getImageManager()->create(null, [
                        'fromImage' => sprintf('%s:%s', $service->getRepository(), $service->getTag())
                    ], ImageManager::FETCH_STREAM);

                    $buildStream->onFrame($this->logger->getBuildCallback());
                    $buildStream->wait();
                } else {
                    throw $e;
                }
            }

            $serviceConfig = $service->getConfig();
            $containerConfig = new ContainerConfig();
            $containerConfig->setImage(sprintf('%s:%s', $service->getRepository(), $service->getTag()));
            $containerConfig->setLabels([
                'com.jolici.container=true'
            ]);

            if (isset($serviceConfig['Env'])) {
                $containerConfig->setEnv($serviceConfig['Env']);
            }

            $containerCreateResult = $this->docker->getContainerManager()->create($containerConfig);
            $this->docker->getContainerManager()->start($containerCreateResult->getId());
            $service->setContainer($containerCreateResult->getId());
        }
    }
public function start(Job $build)
    {
        foreach ($build->getServices() as $service) {
            try {
                $this->docker->getImageManager()->find(sprintf('%s:%s', $service->getRepository(), $service->getTag()));
            } catch (ClientErrorException $e) {
                if ($e->getResponse()->getStatusCode() == 404) {
                    $buildStream = $this->docker->getImageManager()->create(null, [
                        'fromImage' => sprintf('%s:%s', $service->getRepository(), $service->getTag())
                    ], ImageManager::FETCH_STREAM);

                    $buildStream->onFrame($this->logger->getBuildCallback());
                    $buildStream->wait();
                } else {
                    throw $e;
                }
            }

            $serviceConfig = $service->getConfig();
            $containerConfig = new ContainerConfig();
            $containerConfig->setImage(sprintf('%s:%s', $service->getRepository(), $service->getTag()));
            $containerConfig->setLabels([
                'com.jolici.container=true'
            ]);

            if (isset($serviceConfig['Env'])) {
                $containerConfig->setEnv($serviceConfig['Env']);
            }

            $containerCreateResult = $this->docker->getContainerManager()->create($containerConfig);
            $this->docker->getContainerManager()->start($containerCreateResult->getId());
            $service->setContainer($containerCreateResult->getId());
        }
    }
Start services for a Job

@param Job $build