getDockerContainers(); $images = $DockerClient->getDockerImages(); $user_prefs = $dockerManPaths['user-prefs']; $autostart_file = $dockerManPaths['autostart-file']; if (!$containers && !$images) { echo "No Docker containers installed"; return; } if (file_exists($user_prefs)) { $prefs = parse_ini_file($user_prefs); $sort = []; foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs) ?? 999; array_multisort($sort,SORT_NUMERIC,$containers); unset($sort); } // Read container info $allInfo = $DockerTemplates->getAllInfo(); $docker = ['var docker=[];']; $null = '0.0.0.0'; $menu = []; $autostart = @file($autostart_file, FILE_IGNORE_NEW_LINES) ?: []; $names = array_map('var_split', $autostart); foreach ($containers as $ct) { $name = $ct['Name']; $id = $ct['Id']; $info = &$allInfo[$name]; $running = $info['running'] ? 1 : 0; $paused = $info['paused'] ? 1 : 0; $is_autostart = $info['autostart'] ? 'true':'false'; $updateStatus = $info['updated']=='true'||$info['updated']=='undef' ? 'true':'false'; $template = $info['template']; $shell = $info['shell']; $webGui = html_entity_decode($info['url']); $support = html_entity_decode($info['Support']); $project = html_entity_decode($info['Project']); $registry = html_entity_decode($info['registry']); $menu[] = sprintf("addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s','%s');", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project),addslashes($registry)); $docker[] = "docker.push({name:'$name',id:'$id',state:$running,pause:$paused,update:'$updateStatus'});"; $shape = $running ? ($paused ? 'pause' : 'play') : 'square'; $status = $running ? ($paused ? 'paused' : 'started') : 'stopped'; $color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text'); $update = $updateStatus=='false' ? 'blue-text' : ''; $icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png'; $image = substr($icon,-4)=='.png' ? "" : (substr($icon,0,5)=='icon-' ? "" : ""); $wait = var_split($autostart[array_search($name,$names)],1); $ports = []; foreach ($ct['Ports'] as $port) { $intern = $running ? ($ct['NetworkMode']=='host' ? $host : $port['IP']) : $null; $extern = $running ? ($port['NAT'] ? $host : $intern) : $null; $ports[] = sprintf('%s:%s/%s%s:%s', $intern, $port['PrivatePort'], strtoupper($port['Type']), $extern, $port['PublicPort']); } $paths = []; $ct['Volumes'] = is_array($ct['Volumes']) ? $ct['Volumes'] : []; foreach ($ct['Volumes'] as $mount) { list($host_path,$container_path,$access_mode) = explode(':',$mount); $paths[] = sprintf('%s%s', htmlspecialchars($container_path), $access_mode=='ro'?'long-arrow-left':'arrows-h', htmlspecialchars($host_path)); } echo ""; if ($template) { $appname = "".htmlspecialchars($name).""; } else { $appname = htmlspecialchars($name); } echo "$image$appname
$status
"; echo "Container ID: $id
"; if ($ct['BaseImage']) echo "".htmlspecialchars(${ct['BaseImage']})."
"; echo "By: "; $registry = $info['registry']; list($author,$version) = explode(':',$ct['Image']); if ($registry) { echo "".htmlspecialchars($author).""; } else { echo htmlspecialchars($author); } echo "
"; if ($updateStatus=='false') { echo "
update ready
"; echo " apply update"; } elseif ($updateStatus=='true') { echo " up-to-date"; echo "
force update
"; } else { echo " not available"; echo "
force update
"; } echo "
$version
"; echo "{$ct['NetworkMode']}"; echo "".implode('
',$ports)."
"; echo "".implode('
',$paths)."
"; echo "0%
"; echo "
0 / 0"; echo ""; echo ""; echo "
"; echo htmlspecialchars(str_replace('Up','Uptime',$ct['Status']))."
Created ".htmlspecialchars($ct['Created'])."
"; } foreach ($images as $image) { if (count($image['usedBy'])) continue; $id = $image['Id']; $menu[] = sprintf("addDockerImageContext('%s','%s');", $id, implode(',',$image['Tags'])); echo ""; echo "(orphan image)
stopped
"; echo "Image ID: $id
"; echo implode(', ',array_map('htmlspecialchars',$image['Tags'])); echo "Created ".htmlspecialchars($image['Created']).""; } echo "\0".implode($menu).implode($docker)."\0".(pgrep('rc.docker')!==false ? 1:0); ?>