diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 141cf064..61d8aa6e 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -364,6 +364,8 @@ class DockerActionManager $portWithProtocol = $value->port . '/' . $value->protocol; $exposedPorts[$portWithProtocol] = null; } + } else { + $requestBody['HostConfig']['NetworkMode'] = 'host'; } if(count($exposedPorts) > 0) { @@ -621,31 +623,31 @@ class DockerActionManager private function ConnectContainerIdToNetwork(string $id, string $internalPort) : void { if ($internalPort === 'host') { - $network = 'host'; - } else { - $network = 'nextcloud-aio'; - $url = $this->BuildApiUrl('networks/create'); - try { - $this->guzzleClient->request( - 'POST', - $url, - [ - 'json' => [ - 'Name' => 'nextcloud-aio', - 'CheckDuplicate' => true, - 'Driver' => 'bridge', - 'Internal' => false, - 'Options' => [ - 'com.docker.network.bridge.enable_icc' => 'true' - ] + return; + } + + $network = 'nextcloud-aio'; + $url = $this->BuildApiUrl('networks/create'); + try { + $this->guzzleClient->request( + 'POST', + $url, + [ + 'json' => [ + 'Name' => 'nextcloud-aio', + 'CheckDuplicate' => true, + 'Driver' => 'bridge', + 'Internal' => false, + 'Options' => [ + 'com.docker.network.bridge.enable_icc' => 'true' ] ] - ); - } catch (RequestException $e) { - // 409 is undocumented and gets thrown if the network already exists. - if ($e->getCode() !== 409) { - throw $e; - } + ] + ); + } catch (RequestException $e) { + // 409 is undocumented and gets thrown if the network already exists. + if ($e->getCode() !== 409) { + throw $e; } }