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.

73 lines
2.6 KiB

9 years ago
<?php
$container=$_REQUEST['container'];
if (!preg_match(',^[a-f0-9]+$,', $container)) exit(1);
exec('docker inspect '.$container, $res, $ret);
if ($ret!=0) exit(1);
$containers=json_decode(join($res), true);
?>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Overview</a></li>
<li><a href="#tabs-2">Logs</a></li>
<li><a href="#tabs-3">Dump</a></li>
</ul>
<div id="tabs-1">
<table class="details docker"><thead>
<tr><th>Name</th><th>Ports</th><th>Volumes</th><th>Links</th><th>Environments</th><th>Image</th><th>Command</th></tr>
</thead><tbody>
<?php
9 years ago
foreach ($containers as $c) {
$name = preg_replace(',^/,', '', $c['Name']);
$ports = "<ul>";
if ($c['NetworkSettings']['Ports']) {
9 years ago
foreach ($c['NetworkSettings']['Ports'] as $from => $to) {
if ($to)
foreach ($to as $p) {
if (isset($p['HostPort']))
$ports.="<li>-p ".($p['HostIp']&&$p['HostIp']!="0.0.0.0"?$p['HostIp'].":":"").$p['HostPort'].':'.$from.'</li>';
9 years ago
}
}
} elseif ($c['HostConfig']['PortBindings']) {
foreach ($c['HostConfig']['PortBindings'] as $from => $to) {
if ($to)
foreach ($to as $p) {
if (isset($p['HostPort']))
$ports.="<li>-p ".($p['HostIp']&&$p['HostIp']!="0.0.0.0"?$p['HostIp'].":":"").$p['HostPort'].':'.$from.'</li>';
}
}
}
9 years ago
$ports .= "</ul>";
$volumes = "?";
$links = "<ul>";
if ($c['HostConfig']['Links'])
foreach ($c['HostConfig']['Links'] as $link)
$links.="<li>--link ".preg_replace(',^/?(.*):/?'.$name.'/?(.*)$,', '${1}:${2}', $link)."</li>";
$links .= "</ul>";
$envs = "<ul>";
if ($c['Config']['Env'])
foreach ($c['Config']['Env'] as $env)
if (!preg_match(',^PATH=,', $env))
$envs.="<li>-e ".$env."</li>";
$envs .= "</ul>";
$image = $c['Config']['Image'];
$command = "";
9 years ago
if ($c['Config']['Cmd']) $command = join(" ", $c['Config']['Cmd']);
$status="dead";
if ($c['State']['Dead']) $status = "dead";
elseif ($c['State']['Restarting']) $status = "restarted";
elseif ($c['State']['Paused']) $status = "paused";
elseif ($c['State']['Running']) $status = "running";
echo '<tr class="'.$status.'"><td><a href="javascript:details('."'".$c['Id']."'",')">'.$name.'</a></td><td>'.$ports.'</td><td>'.$volumes.'</td><td>'.$links.'</td><td>'.$envs.'</td><td>'.$image.'</td><td>'.$command.'</td></tr>'."\n";
9 years ago
}
echo "</tbody></table>";
echo'</div><div id="tabs-2">';
exec('docker logs '.$container, $logs, $ret);
echo "<pre>\n".join("\n", $logs)."\n</pre>";
echo'</div><div id="tabs-3">';
echo "<pre>\n".join("\n", $res)."\n</pre>";
echo'</div></div>';
9 years ago
?>
<script>
$(function() {$("#tabs").tabs();});
</script>