* Changes

- Revert commit #ed5fe721d9cdfeb65148a5f12eebdf35729e1dfb
- Fix php errors

* Update DockerContainers.page

- Change `External IP:Port` to `LAN IP:Port`
This commit is contained in:
Christoph Hummer
2024-08-08 06:58:58 +02:00
committed by GitHub
parent 9c2aa45751
commit 8cabad6f0d
2 changed files with 32 additions and 32 deletions

View File

@@ -31,7 +31,7 @@ $cpus = cpu_list();
<link type="text/css" rel="stylesheet" href="<?autov("/plugins/dynamix.docker.manager/styles/style-$theme.css")?>">
<table id="docker_containers" class="tablesorter shift">
<thead><tr><th><a id="resetsort" class="nohand" onclick="resetSorting()" title="_(Reset sorting)_"><i class="fa fa-th-list"></i></a>_(Application)_</th><th>_(Version)_</th><th>_(Network)_</th><th>_(Container IP)_</th><th>_(Container Port)_</th><th>_(External IP:Port)_</th><th>_(Volume Mappings)_ <small>(_(App to Host)_)</small></th><th class="load advanced">_(CPU & Memory load)_</th><th class="nine">_(Autostart)_</th><th class="five">_(Uptime)_</th></tr></thead>
<thead><tr><th><a id="resetsort" class="nohand" onclick="resetSorting()" title="_(Reset sorting)_"><i class="fa fa-th-list"></i></a>_(Application)_</th><th>_(Version)_</th><th>_(Network)_</th><th>_(Container IP)_</th><th>_(Container Port)_</th><th>_(LAN IP:Port)_</th><th>_(Volume Mappings)_ <small>(_(App to Host)_)</small></th><th class="load advanced">_(CPU & Memory load)_</th><th class="nine">_(Autostart)_</th><th class="five">_(Uptime)_</th></tr></thead>
<tbody id="docker_list"><tr><td colspan='9'></td></tr></tbody>
</table>
<input type="button" onclick="addContainer()" value="_(Add Container)_" style="display:none">

View File

@@ -323,10 +323,10 @@ class DockerTemplates {
} else {
if ($ct['NetworkMode']=='host') {
$ip = $host;
} elseif ($driver[$ct['NetworkMode']]=='ipvlan' || $driver[$ct['NetworkMode']]=='macvlan') {
} elseif (isset($driver[$ct['NetworkMode']]) && ($driver[$ct['NetworkMode']] == 'ipvlan' || $driver[$ct['NetworkMode']] == 'macvlan')) {
$ip = reset($ct['Networks'])['IPAddress'];
} elseif (!is_null(_var($port,'PublicPort'))) {
$ip = $host;
$ip = $host;
} else {
$ip = _var($port,'IP');
}
@@ -938,38 +938,39 @@ class DockerClient {
$c['Ports'] = [];
$c['Networks'] = [];
if ($id) $c['NetworkMode'] = $net.str_replace('/',':',DockerUtil::ctMap($id)?:'/???');
if ($info['State']['Running']) {
if (isset($driver[$c['NetworkMode']])) {
if ($driver[$c['NetworkMode']]=='bridge') {
$ports = &$info['HostConfig']['PortBindings'];
} elseif ($driver[$c['NetworkMode']]=='host') {
$c['Ports']['host'] = ['host' => ''];
} elseif ($driver[$c['NetworkMode']]=='ipvlan' || $driver[$c['NetworkMode']]=='macvlan') {
$c['Ports']['vlan'] = ['vlan' => ''];
} else {
$ports = &$info['Config']['ExposedPorts'];
}
} else if (!$id) {
$c['NetworkMode'] = DockerUtil::ctMap($c['NetworkMode']);
if (isset($driver[$c['NetworkMode']])) {
if ($driver[$c['NetworkMode']]=='bridge') {
$ports = &$info['HostConfig']['PortBindings'];
} elseif ($driver[$c['NetworkMode']]=='host') {
$c['Ports']['host'] = ['host' => ''];
} elseif ($driver[$c['NetworkMode']]=='ipvlan' || $driver[$c['NetworkMode']]=='macvlan') {
$c['Ports']['vlan'] = ['vlan' => ''];
} else {
$ports = &$info['Config']['ExposedPorts'];
foreach($ct['NetworkSettings']['Networks'] as $netName => $netVals) {
$i = $c['NetworkMode']=='host' ? $host : $netVals['IPAddress'];
$c['Networks'][$netName] = [ 'IPAddress' => $i ];
}
}
$ip = $c['NetworkMode']=='host' ? $host : $ct['NetworkSettings']['Networks'][$c['NetworkMode']]['IPAddress'] ?? null;
$c['Networks'][$c['NetworkMode']] = [ 'IPAddress' => $ip ];
$ports = (isset($ports) && is_array($ports)) ? $ports : [];
foreach ($ports as $port => $value) {
[$PrivatePort, $Type] = array_pad(explode('/', $port),2,'');
$PublicPort = $info['HostConfig']['PortBindings']["$port"][0]['HostPort'] ?: null;
$nat = ($driver[$c['NetworkMode']]=='bridge');
if (array_key_exists($PrivatePort, $c['Ports']) && $Type != $c['Ports'][$PrivatePort]['Type'])
$Type = $c['Ports'][$PrivatePort]['Type'] . '/' . $Type;
$c['Ports'][$PrivatePort] = ['IP' => $ip, 'PrivatePort' => $PrivatePort, 'PublicPort' => $PublicPort, 'NAT' => $nat, 'Type' => $Type, 'Driver' => $driver[$c['NetworkMode']]];
} else if (!$id) {
$c['NetworkMode'] = DockerUtil::ctMap($c['NetworkMode']);
$ports = &$info['Config']['ExposedPorts'];
foreach($ct['NetworkSettings']['Networks'] as $netName => $netVals) {
$i = $c['NetworkMode']=='host' ? $host : $netVals['IPAddress'];
$c['Networks'][$netName] = [ 'IPAddress' => $i ];
}
ksort($c['Ports']);
}
$ip = $c['NetworkMode']=='host' ? $host : $ct['NetworkSettings']['Networks'][$c['NetworkMode']]['IPAddress'] ?? null;
$c['Networks'][$c['NetworkMode']] = [ 'IPAddress' => $ip ];
$ports = (isset($ports) && is_array($ports)) ? $ports : [];
foreach ($ports as $port => $value) {
if (!isset($info['HostConfig']['PortBindings'][$port])) {
continue;
}
[$PrivatePort, $Type] = array_pad(explode('/', $port),2,'');
$PublicPort = $info['HostConfig']['PortBindings']["$port"][0]['HostPort'] ?: null;
$nat = ($driver[$c['NetworkMode']]=='bridge');
if (array_key_exists($PrivatePort, $c['Ports']) && $Type != $c['Ports'][$PrivatePort]['Type'])
$Type = $c['Ports'][$PrivatePort]['Type'] . '/' . $Type;
$c['Ports'][$PrivatePort] = ['IP' => $ip, 'PrivatePort' => $PrivatePort, 'PublicPort' => $PublicPort, 'NAT' => $nat, 'Type' => $Type, 'Driver' => $driver[$c['NetworkMode']]];
}
ksort($c['Ports']);
$this::$containersCache[] = $c;
}
array_multisort(array_column($this::$containersCache,'Name'), SORT_NATURAL|SORT_FLAG_CASE, $this::$containersCache);
@@ -1117,4 +1118,3 @@ class DockerUtil {
}
}
?>