From a257443293335281a21e9a121b4a6f4eee157943 Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Tue, 15 Aug 2023 10:31:19 +0200 Subject: [PATCH] Try docker stop command, if the stop with DockerClient did not worked. --- src/include/ABHelper.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/include/ABHelper.php b/src/include/ABHelper.php index 35291f2..28d60b1 100644 --- a/src/include/ABHelper.php +++ b/src/include/ABHelper.php @@ -152,7 +152,14 @@ public static function stopContainer($container) { $stopTimer = time(); $dockerStopCode = $dockerClient->stopContainer($container['Name']); if ($dockerStopCode != 1) { - self::backupLog("Error while stopping container! Code: " . $dockerStopCode, self::LOGLEVEL_ERR, true, true); + self::backupLog("Error while stopping container! Code: " . $dockerStopCode . " - trying 'docker stop' method", self::LOGLEVEL_ERR, true, true); + $out = $code = null; + exec("docker stop " . escapeshellarg($container['Name']) . " -t 30", $out, $code); + if ($code == 0) { + self::backupLog("That _seemed_ to work."); + } else { + self::backupLog("docker stop variant was unsuccessful as well! Docker said: " . implode(', ', $out), self::LOGLEVEL_ERR); + } } else { self::backupLog("done! (took " . (time() - $stopTimer) . " seconds)", self::LOGLEVEL_INFO, true, true); }