Merge pull request #1655 from nextcloud/enh/noid/fix-adding-containers-to-host-network

fix adding containers to the host network
This commit is contained in:
Simon L 2023-01-02 17:56:50 +01:00 committed by GitHub
commit cd06678191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -364,6 +364,8 @@ class DockerActionManager
$portWithProtocol = $value->port . '/' . $value->protocol; $portWithProtocol = $value->port . '/' . $value->protocol;
$exposedPorts[$portWithProtocol] = null; $exposedPorts[$portWithProtocol] = null;
} }
} else {
$requestBody['HostConfig']['NetworkMode'] = 'host';
} }
if(count($exposedPorts) > 0) { if(count($exposedPorts) > 0) {
@ -621,8 +623,9 @@ class DockerActionManager
private function ConnectContainerIdToNetwork(string $id, string $internalPort) : void private function ConnectContainerIdToNetwork(string $id, string $internalPort) : void
{ {
if ($internalPort === 'host') { if ($internalPort === 'host') {
$network = 'host'; return;
} else { }
$network = 'nextcloud-aio'; $network = 'nextcloud-aio';
$url = $this->BuildApiUrl('networks/create'); $url = $this->BuildApiUrl('networks/create');
try { try {
@ -647,7 +650,6 @@ class DockerActionManager
throw $e; throw $e;
} }
} }
}
$url = $this->BuildApiUrl( $url = $this->BuildApiUrl(
sprintf('networks/%s/connect', $network) sprintf('networks/%s/connect', $network)