\n";
echo "Name | Ports | Links | Image | Actions |
\n";
echo "";
foreach ($containers as $c) {
$name = preg_replace(',^/,', '', $c['Name']);
$ports = "";
if ($c['NetworkSettings']['Ports'])
foreach ($c['NetworkSettings']['Ports'] as $from => $to) {
if ($to)
foreach ($to as $p) {
if (isset($p['HostPort']))
$ports.="- ".($p['HostIp']!="0.0.0.0"?$p['HostIp'].":":"").$p['HostPort'].':'.$from.'
';
}
}
$ports .= "
";
$links = "";
if ($c['HostConfig']['Links'])
foreach ($c['HostConfig']['Links'] as $link)
$links.="- ".preg_replace(',^/?(.*):/?'.$name.'/?(.*)$,', '${1}:${2}', $link)."
";
$links .= "
";
$image = $c['Config']['Image'];
if ($c['State']['Dead']) {$status = "dead"; $actions=Array("start", "rm");}
elseif ($c['State']['Restarting']) {$status = "restarted"; $actions=Array();}
elseif ($c['State']['Paused']) {$status = "paused"; $actions=Array("unpause", "rm");}
elseif ($c['State']['Running']) {$status = "running"; $actions=Array("pause", "stop");}
else {$status="dead"; $actions=Array("start", "remove");}
$action="";
foreach($actions as $a)
$action.=''.$a.'';
echo ''.$name.' | '.$ports.' | '.$volumes.' | '.$links.' | '.$envs.' | '.$image.' | '.$command.' | | '.$action.' |
'."\n";
}
echo "";
?>