From 9506bfaa84ee3cd4a54637bd1c586fa51cd7a15a Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 20 Nov 2023 13:27:51 +0100 Subject: [PATCH] Make sure that image is correctly pulled before continuing Signed-off-by: Simon L --- php/src/Docker/DockerActionManager.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 0c64ee527d77..8030580bdf8f 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -579,9 +579,15 @@ public function CreateContainer(Container $container) : void { public function PullContainer(Container $container) : void { - $url = $this->BuildApiUrl(sprintf('images/create?fromImage=%s', urlencode($this->BuildImageName($container)))); - // do not catch any exception so that it always throws and logs the error - $this->guzzleClient->post($url); + $imageName = urlencode($this->BuildImageName($container)); + $url = $this->BuildApiUrl(sprintf('images/create?fromImage=%s', $imageName)); + try { + $this->guzzleClient->post($url); + $imageUrl = $this->BuildApiUrl(sprintf('images/%s/json', $imageName)); + $this->guzzleClient->get($imageUrl)->getBody()->getContents(); + } catch (\Throwable $e) { + throw new \Exception("Could not pull image " . $imageName ". Please run 'sudo docker exec -it nextcloud-aio-mastercontainer docker pull " . $imageName . "' in order to find out why it failed."); + } } private function isContainerUpdateAvailable(string $id) : string