mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 06:26:57 +00:00
allow to add container to host network
Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
parent
117c3de7c5
commit
cea32f50af
1 changed files with 35 additions and 28 deletions
|
|
@ -124,8 +124,9 @@ class DockerActionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
$containerName = $container->GetIdentifier();
|
$containerName = $container->GetIdentifier();
|
||||||
if ($container->GetInternalPort() !== "") {
|
$internalPort = $container->GetInternalPort();
|
||||||
$connection = @fsockopen($containerName, (int)$container->GetInternalPort(), $errno, $errstr, 0.1);
|
if ($internalPort !== "" && $internalPort !== 'host') {
|
||||||
|
$connection = @fsockopen($containerName, (int)$internalPort, $errno, $errstr, 0.1);
|
||||||
if ($connection) {
|
if ($connection) {
|
||||||
fclose($connection);
|
fclose($connection);
|
||||||
return new RunningState();
|
return new RunningState();
|
||||||
|
|
@ -216,9 +217,11 @@ class DockerActionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
$exposedPorts = [];
|
$exposedPorts = [];
|
||||||
|
if ($container->GetInternalPort() !== 'host') {
|
||||||
foreach($container->GetPorts()->GetPorts() as $port) {
|
foreach($container->GetPorts()->GetPorts() as $port) {
|
||||||
$exposedPorts[$port] = null;
|
$exposedPorts[$port] = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$requestBody = [
|
$requestBody = [
|
||||||
'Image' => $this->BuildImageName($container),
|
'Image' => $this->BuildImageName($container),
|
||||||
|
|
@ -566,7 +569,6 @@ class DockerActionManager
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// get the id from the response
|
|
||||||
$id = $response['Id'];
|
$id = $response['Id'];
|
||||||
|
|
||||||
// start the exec
|
// start the exec
|
||||||
|
|
@ -606,8 +608,12 @@ class DockerActionManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function ConnectContainerIdToNetwork(string $id) : void
|
private function ConnectContainerIdToNetwork(string $id, string $internalPort) : void
|
||||||
{
|
{
|
||||||
|
if ($internalPort === 'host') {
|
||||||
|
$network = 'host';
|
||||||
|
} else {
|
||||||
|
$network = 'nextcloud-aio';
|
||||||
$url = $this->BuildApiUrl('networks/create');
|
$url = $this->BuildApiUrl('networks/create');
|
||||||
try {
|
try {
|
||||||
$this->guzzleClient->request(
|
$this->guzzleClient->request(
|
||||||
|
|
@ -631,9 +637,10 @@ class DockerActionManager
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$url = $this->BuildApiUrl(
|
$url = $this->BuildApiUrl(
|
||||||
sprintf('networks/%s/connect', 'nextcloud-aio')
|
sprintf('networks/%s/connect', $network)
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
$this->guzzleClient->request(
|
$this->guzzleClient->request(
|
||||||
|
|
@ -655,12 +662,12 @@ class DockerActionManager
|
||||||
|
|
||||||
public function ConnectMasterContainerToNetwork() : void
|
public function ConnectMasterContainerToNetwork() : void
|
||||||
{
|
{
|
||||||
$this->ConnectContainerIdToNetwork('nextcloud-aio-mastercontainer');
|
$this->ConnectContainerIdToNetwork('nextcloud-aio-mastercontainer', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ConnectContainerToNetwork(Container $container) : void
|
public function ConnectContainerToNetwork(Container $container) : void
|
||||||
{
|
{
|
||||||
$this->ConnectContainerIdToNetwork($container->GetIdentifier());
|
$this->ConnectContainerIdToNetwork($container->GetIdentifier(), $container->GetInternalPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StopContainer(Container $container) : void {
|
public function StopContainer(Container $container) : void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue