diff --git a/Changelog.md b/Changelog.md index 753b3d39..8ba2063b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,11 @@ # Changelog +## 3.2.9 / 2019-12-11 + +### Fixed: + + * Harden handling of getting actual container name from a service + ## 3.2.8 / 2019-12-10 ### Fixed diff --git a/src/Method/DockerMethod.php b/src/Method/DockerMethod.php index 4ed28a8c..d00770d0 100644 --- a/src/Method/DockerMethod.php +++ b/src/Method/DockerMethod.php @@ -207,7 +207,7 @@ public function waitForServices(HostConfig $hostconfig, TaskContextInterface $co if (!$this->isContainerRunning($docker_config, $container_name)) { throw new \RuntimeException(sprintf( - 'Docker container %s not running, check your `host.docker.name` configuration!', + 'Docker container %s is not running or could not be discovered! Check your docker config!', $container_name )); } @@ -561,20 +561,18 @@ public static function getDockerContainerName(HostConfig $host_config, Configura $shell = $docker_config->shell(); $cwd = $shell->getWorkingDir(); $shell->cd(self::getProjectFolder($docker_config, $host_config)); - $result = $shell->run('#!docker-compose ps', true); + $result = $shell->run(sprintf('#!docker-compose ps -q %s', $composer_service), true); $shell->cd($cwd); $docker_name = false; + if ($result->succeeded()) { + $docker_name = $result->getOutput()[0]; + $cfg = $host_config['docker']; + $cfg['name'] = $docker_name; + $host_config['docker'] = $cfg; - foreach ($result->getOutput() as $line) { - if (strpos($line, '_' . $composer_service . '_') !== false) { - list($docker_name) = explode(' ', $line); - $cfg = $host_config['docker']; - $cfg['name'] = $docker_name; - $host_config['docker'] = $cfg; - - return $docker_name; - } + return $docker_name; } + throw new \RuntimeException(sprintf( 'Could not get the name of the docker container running the service `%s`', $composer_service diff --git a/src/Utilities/Utilities.php b/src/Utilities/Utilities.php index 2ad03652..18be907c 100644 --- a/src/Utilities/Utilities.php +++ b/src/Utilities/Utilities.php @@ -8,7 +8,7 @@ class Utilities { - const FALLBACK_VERSION = '3.2.8'; + const FALLBACK_VERSION = '3.2.9'; public static function mergeData(array $data, array $override_data): array {