mirror of
https://github.com/myronblair/novacpx
synced 2026-06-30 17:50:41 -05:00
fix: docker image-remove throws on daemon error; add sync-orphans endpoint
- removeImage now throws RuntimeException when docker rmi output contains 'Error' or 'conflict' so the API returns success:false with the message - Added docker/sync-orphans endpoint (admin only) to register existing Docker containers not tracked in the NovaCPX DB (e.g. after a restore)
This commit is contained in:
@@ -190,7 +190,11 @@ SH;
|
||||
|
||||
public function removeImage(string $imageId): string {
|
||||
if (!preg_match('/^[a-zA-Z0-9:._\-\/]+$/', $imageId)) throw new RuntimeException("Invalid image ID");
|
||||
return trim(shell_exec("sudo docker rmi " . escapeshellarg($imageId) . " 2>&1") ?? '');
|
||||
$out = trim(shell_exec("sudo docker rmi " . escapeshellarg($imageId) . " 2>&1") ?? '');
|
||||
if (stripos($out, "Error") !== false || stripos($out, "conflict") !== false) {
|
||||
throw new \RuntimeException($out);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
// ── Volumes & Networks ────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user