Files
servicedock/html/images.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2015-11-19 13:13:05 +00:00
<?php
exec("docker images -aq", $res, $ret);
if ($ret!=0) {
echo ' A [label="Error\nCannot get Docker Images"];';
echo ' B [label="Does the Webserver have Docker rights?"];';
echo ' A->B [label="Probable\nCause"];';
return;
}
exec("docker inspect ".join(" ", $res), $res2, $ret);
if ($ret==0) {
$images=json_decode(join($res2), true);
foreach ($images as $i) {
$name = "";
if (isset($i['RepoTags']) && count($i['RepoTags'])>0) {
$name = join("\\n", $i['RepoTags']);
if (isset($i['Author']) && $i['Author']!="") $name .= '\\n['.$i['Author'].']';
2015-11-20 15:14:56 +00:00
echo ' "'.$i['Id'].'" [label="'.$name.'"];'."\n";
2015-11-19 13:13:05 +00:00
}
}
foreach ($images as $i) {
2015-11-20 15:14:56 +00:00
if (isset($i['RepoTags']) && count($i['RepoTags'])>0) {
for ($p = $i['Parent']; isset($p) && $p!="";) {
$next = null;
foreach ($images as $i2)
if ($i2['Id'] == $p) {
$next = $i2;
break;
}
if (!$next) break;
$p = $next['Parent'];
if (isset($next['RepoTags']) && count($next['RepoTags'])>0) {
echo ' "'.$next['Id'].'" -> "'.$i['Id'].'";'."\n";
break;
}
}
}
2015-11-19 13:13:05 +00:00
}
} else {
echo ' A [label="Error\nCannot Inspect Docker Container"];';
return;
}
?>