first release
This commit is contained in:
		
							
								
								
									
										45
									
								
								html/details.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								html/details.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
<?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);
 | 
			
		||||
echo "<table class=\"details docker\"><thead>\n";
 | 
			
		||||
echo "<tr><th>Name</th><th>Ports</th><th>Volumes</th><th>Links</th><th>Environments</th><th>Image</th><th>Command</th></tr>\n";
 | 
			
		||||
echo "</thead><tbody>";
 | 
			
		||||
foreach ($containers as $c) {
 | 
			
		||||
  $name = preg_replace(',^/,', '', $c['Name']);
 | 
			
		||||
  $ports = "<ul>";
 | 
			
		||||
  if ($c['NetworkSettings']['Ports'])
 | 
			
		||||
    foreach ($c['NetworkSettings']['Ports'] as $from => $to) {
 | 
			
		||||
      if ($to)
 | 
			
		||||
        foreach ($to as $p) {
 | 
			
		||||
          if (isset($p['HostPort']))
 | 
			
		||||
            $ports.="<li>-p ".($p['HostIp']!="0.0.0.0"?$p['HostIp'].":":"").$p['HostPort'].':'.$from.'</li>';
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  $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'];
 | 
			
		||||
  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>docker run -d --name ${name}</td><td>${ports}</td><td>${volumes}</td><td>${links}</td><td>${envs}</td><td>${image}</td><td>${command}</th></tr>\n";
 | 
			
		||||
}
 | 
			
		||||
echo "</tbody></table>";
 | 
			
		||||
echo "<pre>\n".join("\n", $res)."\n</pre>"
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user