mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-10-05 13:04:32 +08:00
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:
commit
cd06678191
1 changed files with 25 additions and 23 deletions
|
@ -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,31 +623,31 @@ 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';
|
|
||||||
$url = $this->BuildApiUrl('networks/create');
|
$network = 'nextcloud-aio';
|
||||||
try {
|
$url = $this->BuildApiUrl('networks/create');
|
||||||
$this->guzzleClient->request(
|
try {
|
||||||
'POST',
|
$this->guzzleClient->request(
|
||||||
$url,
|
'POST',
|
||||||
[
|
$url,
|
||||||
'json' => [
|
[
|
||||||
'Name' => 'nextcloud-aio',
|
'json' => [
|
||||||
'CheckDuplicate' => true,
|
'Name' => 'nextcloud-aio',
|
||||||
'Driver' => 'bridge',
|
'CheckDuplicate' => true,
|
||||||
'Internal' => false,
|
'Driver' => 'bridge',
|
||||||
'Options' => [
|
'Internal' => false,
|
||||||
'com.docker.network.bridge.enable_icc' => 'true'
|
'Options' => [
|
||||||
]
|
'com.docker.network.bridge.enable_icc' => 'true'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
]
|
||||||
} catch (RequestException $e) {
|
);
|
||||||
// 409 is undocumented and gets thrown if the network already exists.
|
} catch (RequestException $e) {
|
||||||
if ($e->getCode() !== 409) {
|
// 409 is undocumented and gets thrown if the network already exists.
|
||||||
throw $e;
|
if ($e->getCode() !== 409) {
|
||||||
}
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue