mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
chore: add container count to image details
This commit is contained in:
parent
8cab528551
commit
6a16e71310
1 changed files with 12 additions and 2 deletions
|
|
@ -10,8 +10,18 @@ class GetServerDockerImageDetails
|
|||
|
||||
public static function run($server, $imageId)
|
||||
{
|
||||
$result = instant_remote_process(["docker inspect --format 'json' --type=image {$imageId}"], $server);
|
||||
$imageDetailsRaw = instant_remote_process(["docker inspect --type=image {$imageId}"], $server);
|
||||
$imageDetails = json_decode($imageDetailsRaw, true);
|
||||
|
||||
return json_decode($result, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
return ['error' => 'Invalid JSON returned from Docker inspect', 'raw_output' => $imageDetailsRaw];
|
||||
}
|
||||
|
||||
$containerCountRaw = instant_remote_process(["docker ps -q --filter ancestor={$imageId} | wc -l"], $server);
|
||||
$containerCount = intval(trim($containerCountRaw)); // Convert to an integer
|
||||
|
||||
$imageDetails[0]['ContainerCount'] = $containerCount;
|
||||
|
||||
return $imageDetails;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue