/** * @param InputInterface $input * @param OutputInterface $output * * @throws \InvalidArgumentException * @return Docker */ protected function getDocker(InputInterface $input, OutputInterface $output) { if ($this->getDefinition()->hasArgument(self::ARGUMENT_TARGET)) { $target = $input->getArgument(self::ARGUMENT_TARGET) ?: $this->project->getCurrentTarget(); } else { $target = $this->project->getCurrentTarget(); } $targets = $this->project->getTargets(); if (false === $targets->offsetExists($target)) { throw new \InvalidArgumentException('You must choose a valid target to start the containers. Valid options are:' . "\n - " . implode("\n - ", array_keys($targets->getArrayCopy()))); } $ssh = $targets->offsetGet($target); /** @var ExecutorFactory $factory */ $factory = $this->getApplication()->getService('executor.factory'); $executor = $factory->createExecutor($output, true, $ssh); /** @var Docker $docker */ $docker = $this->getApplication()->getService('docker'); $docker->setExecutor($executor); return $docker; }