mirror of
https://github.com/unraid/webgui.git
synced 2026-04-26 12:20:42 -05:00
Docker custom networks
This commit is contained in:
@@ -239,8 +239,8 @@ _(Template Authoring Mode)_:
|
||||
:docker_authoring_mode_help:
|
||||
|
||||
_(Host access to custom networks)_:
|
||||
: <select name="DOCKER_ALLOW_ACCESS" disabled>
|
||||
<?=mk_option($dockercfg['DOCKER_ALLOW_ACCESS'], '', _('Disabled'),'selected')?>
|
||||
: <select name="DOCKER_ALLOW_ACCESS">
|
||||
<?=mk_option($dockercfg['DOCKER_ALLOW_ACCESS'], '', _('Disabled'))?>
|
||||
<?=mk_option($dockercfg['DOCKER_ALLOW_ACCESS'], 'yes', _('Enabled'))?>
|
||||
</select>
|
||||
|
||||
@@ -437,7 +437,7 @@ _(Docker LOG rotation)_:
|
||||
:docker_log_rotation_active_help:
|
||||
|
||||
_(Host access to custom networks)_:
|
||||
: <?=($dockercfg['DOCKER_ALLOW_ACCESS']||1) ? _('Disabled') : _('Enabled')?>
|
||||
: <?=$dockercfg['DOCKER_ALLOW_ACCESS']=='yes' ? _('Enabled') : _('Disabled')?>
|
||||
|
||||
:docker_custom_network_active_help:
|
||||
|
||||
|
||||
@@ -1001,7 +1001,7 @@ class DockerUtil {
|
||||
}
|
||||
|
||||
public static function custom() {
|
||||
return static::docker("network ls --filter driver='bridge' --filter driver='ipvlan' --format='{{.Name}}'|grep -v '^bridge$'",true);
|
||||
return static::docker("network ls --filter driver='bridge' --filter driver='macvlan' --filter driver='ipvlan' --format='{{.Name}}' 2>/dev/null|grep -v '^bridge$'",true);
|
||||
}
|
||||
|
||||
public static function network($custom) {
|
||||
|
||||
@@ -292,8 +292,9 @@ function xmlToCommand($xml, $create_paths=false) {
|
||||
} elseif ($confType == 'port') {
|
||||
switch ($driver[$xml['Network']]) {
|
||||
case 'host':
|
||||
case 'macvlan':
|
||||
case 'ipvlan':
|
||||
// Export ports as variable if network is set to host or ipvlan
|
||||
// Export ports as variable if network is set to host or macvlan or ipvlan
|
||||
$Variables[] = strtoupper(escapeshellarg($Mode.'_PORT_'.$containerConfig).'='.escapeshellarg($hostConfig));
|
||||
break;
|
||||
case 'bridge':
|
||||
|
||||
@@ -19,17 +19,17 @@ Nchan="wg_poller"
|
||||
$etc = '/etc/wireguard';
|
||||
$tmp = '/tmp/list.tmp';
|
||||
|
||||
unset($subnets,$hosts,$subnets6,$hosts6,$vtuns,$ipvlan,$docker);
|
||||
unset($subnets,$hosts,$subnets6,$hosts6,$vtuns,$filter,$docker);
|
||||
exec("ip -4 route show scope link|awk '/^[^d].+ dev (eth|br|bond)[0-9]+/{print \$1}'",$subnets);
|
||||
exec("ip -4 addr show scope global|awk '/inet .+ (eth|br|bond)[0-9]+/{split(\$2,ip,\"/\");print ip[1]}'",$hosts);
|
||||
exec("ip -6 route show type unicast|grep -Pv 'expires|shim-'|awk '/^[^dfm:]/{print \$1}'",$subnets6);
|
||||
exec("ip -6 addr show scope global|grep -PA2 ': (eth|br|bond)\d+'|awk '/inet6 .+ (global|noprefixroute) \$/{split(\$2,ip,\"/\");print ip[1]}'",$hosts6);
|
||||
exec("ls --indicator-style=none $etc/wg*.conf*|grep -Po wg[0-9]+",$vtuns);
|
||||
exec("docker network ls --filter driver='ipvlan' --format='{{.Name}}' 2>/dev/null",$ipvlan);
|
||||
exec("docker network ls --filter driver='macvlan' --filter driver='ipvlan' --format='{{.Name}}' 2>/dev/null",$filter);
|
||||
|
||||
// add subnets defined in Docker custom networks
|
||||
if (count($ipvlan)) {
|
||||
exec("docker network inspect --format='{{range .IPAM.Config}}{{println .Subnet}}{{end}}' ".implode(' ',$ipvlan),$docker);
|
||||
if (count($filter)) {
|
||||
exec("docker network inspect --format='{{range .IPAM.Config}}{{println .Subnet}}{{end}}' ".implode(' ',$filter),$docker);
|
||||
foreach (array_filter($docker) as $network) {
|
||||
if (strpos($network,'.')!==false && !in_array($network,$subnets)) $subnets[] = $network;
|
||||
elseif (strpos($network,':')!==false && !in_array($network,$subnets6)) $subnets6[] = $network;
|
||||
|
||||
Reference in New Issue
Block a user