diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index bb57ec91..06bc52a9 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -48,6 +48,15 @@ class DockerController } } + // Check if docker hub is reachable in order to make sure that we do not try to pull an image if it is down + // and try to mitigate issues that are arising due to that + if ($pullImage) { + if (!$this->dockerActionManager->isDockerHubReachable($container)) { + $pullImage = false; + error_log('Not pulling the image for the ' . $container->GetContainerName() . ' container because docker hub does not seem to be reachable.'); + } + } + $this->dockerActionManager->DeleteContainer($container); $this->dockerActionManager->CreateVolumes($container); if ($pullImage) { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 79dd069a..d71edecc 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -587,6 +587,21 @@ class DockerActionManager } + public function isDockerHubReachable(Container $container) : bool { + $tag = $container->GetImageTag(); + if ($tag === '%AIO_CHANNEL%') { + $tag = $this->GetCurrentChannel(); + } + + $remoteDigest = $this->dockerHubManager->GetLatestDigestOfTag($container->GetContainerName(), $tag); + + if ($remoteDigest === null) { + return false; + } else { + return true; + } + } + public function PullImage(Container $container) : void { $imageName = $this->BuildImageName($container);