getDockerContainers(); $images = $DockerClient->getDockerImages(); $user_prefs = $dockerManPaths['user-prefs']; 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 = []; $n = 0; 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']; $webGui = html_entity_decode($info['url']); $support = html_entity_decode($info['Support']); $project = html_entity_decode($info['Project']); $menu[] = sprintf("addDockerContainerContext('%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), $id, addslashes($support), addslashes($project)); $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'; $icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png'; $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 = []; 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 ""; echo "
"; echo ""; echo "
"; echo ""; if ($template) { echo "".htmlspecialchars($name).""; } else { echo htmlspecialchars($name); } echo "
Container ID: $id
"; if ($ct['BaseImage']) echo "
".htmlspecialchars(${ct['BaseImage']})."
"; echo "
By:"; $registry = $info['registry']; if ($registry) { echo "".htmlspecialchars($ct['Image']).""; } else { echo htmlspecialchars($ct['Image']); } echo "
"; if ($updateStatus=='false') { echo " update ready"; } elseif ($updateStatus=='true') { echo " up-to-date"; echo "
force update
"; } else { echo " not available"; echo "
force update
"; } echo "{$ct['NetworkMode']}"; echo "".implode('
',$ports)."
"; echo "".implode('
',$paths)."
"; 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 "
"; echo "
"; echo ""; echo "
"; echo "(orphan image)
Image ID: $id
"; echo "
".implode('
',array_map('htmlspecialchars',$image['Tags']))."
"; echo " "; echo "
Created ".htmlspecialchars($image['Created'])."
"; } echo "\0".implode($menu).implode($docker); ?>