diff --git a/emhttp/languages/en_US/helptext.txt b/emhttp/languages/en_US/helptext.txt index e3fcb4a19..5dfac30c2 100644 --- a/emhttp/languages/en_US/helptext.txt +++ b/emhttp/languages/en_US/helptext.txt @@ -2379,6 +2379,12 @@ Generally speaking, it is recommended to leave this setting to its default value IMPORTANT NOTE: If adjusting port mappings, do not modify the settings for the Container port as only the Host port can be adjusted. :end +:docker_fixed_mac_help: +Assigns the container's MAC address on the selected Docker network endpoint. Use a valid unicast MAC address; the first octet must be even, e.g. 02:42:9a:0d:7e:c0. + +This avoids using the legacy container-level --mac-address option in Extra Parameters. +:end + :docker_container_network_help: This allows your container to utilize the network configuration of another container. Select the appropriate container from the list.
This setup can be particularly beneficial if you wish to route your container's traffic through a VPN. :end diff --git a/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php b/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php index 794faadfb..2966cf214 100755 --- a/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php +++ b/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php @@ -202,10 +202,9 @@ function cpu_pinning() { if (preg_match('/^container:(.*)/', $Network)) { $Net_Container = str_replace("container:", "", $Network); } else { - preg_match("/--(net|network)=container:[^\s]+/", $ExtraParams, $NetworkParam); - if (!empty($NetworkParam[0])) { - $Net_Container = explode(':', $NetworkParam[0])[1]; - $Net_Container = str_replace(['"', "'"], '', $Net_Container); + preg_match("/--(?:net|network)(?:=|\s+)(['\"]?)container:([^'\"\s]+)\\1/", $ExtraParams, $NetworkParam); + if (!empty($NetworkParam[2])) { + $Net_Container = $NetworkParam[2]; } } // check if the container still exists from which the network should be used, if it doesn't exist any more recreate container with network none and don't start it @@ -213,7 +212,7 @@ function cpu_pinning() { $Net_Container_ID = $DockerClient->getContainerID($Net_Container); if (empty($Net_Container_ID)) { $cmd = str_replace('/docker run -d ', '/docker create ', $cmd); - $cmd = preg_replace("/--(net|network)=(['\"]?)container:[^'\"]+\\2/", "--network=none ", $cmd); + $cmd = preg_replace("/--(?:net|network)(?:=|\s+)(['\"]?)container:[^'\"\s]+\\1/", "--network=none ", $cmd); } } // force kill container if still running after time-out @@ -736,6 +735,8 @@ function removeConfig(num) { function prepareConfig(form) { var types = [], values = [], targets = [], vcpu = []; + var myMAC = $(form).find('input[name="contMyMAC"]').val().trim().replaceAll('-', ':').toLowerCase(); + $(form).find('input[name="contMyMAC"]').val(myMAC); if ($('select[name="contNetwork"]').val()=='host') { $(form).find('input[name="confType[]"]').each(function(){types.push($(this).val());}); $(form).find('input[name="confValue[]"]').each(function(){values.push($(this));}); @@ -744,6 +745,7 @@ function prepareConfig(form) { } $(form).find('input[id^="box"]').each(function(){if ($(this).prop('checked')) vcpu.push($('#'+$(this).prop('id').replace('box','cpu')).text());}); form.contCPUset.value = vcpu.join(','); + return true; } function makeName(type) { @@ -893,7 +895,7 @@ function prepareCategory() { ?>
-
+ @@ -1111,6 +1113,14 @@ function prepareCategory() {
+
+_(Fixed MAC address)_ (_(optional)_): +: + +:docker_fixed_mac_help: + +
+
_(Container Network)_: :