Servicedock: Webgui for Docker Swarm. Manage Docker Swarm a a Service.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
1.4 KiB

<?php
exec("docker images -aq", $res, $ret);
if ($ret!=0) {
echo 'digraph {';
echo ' A [label="Error\nCannot get Docker Images"];';
echo ' B [label="Does the Webserver have Docker rights?"];';
echo ' A->B [label="Probable\nCause"];';
echo '}';
return;
}
exec("docker inspect ".join(" ", $res), $res2, $ret);
if ($ret==0) {
$images=json_decode(join($res2), true);
echo "digraph {\n";
echo " rankdir=TB;\n";
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'].']';
echo ' "'.$i['Id'].'" [label="'.$name.'"];'."\n";
}
}
foreach ($images as $i) {
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;
}
}
}
}
echo "}";
} else {
echo 'digraph {';
echo ' A [label="Error\nCannot Inspect Docker Container"];';
echo '}';
return;
}
?>