diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index cd857b1b..9fdbf1c7 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -211,9 +211,16 @@ class DockerActionManager public function CreateContainer(Container $container) : void { $volumes = []; - foreach($container->GetVolumes()->GetVolumes() as $volume) { + foreach ($container->GetVolumes()->GetVolumes() as $volume) { + // NEXTCLOUD_MOUNT gets added via bind-mount later on + if ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') { + if ($volume->name === $this->configurationManager->GetNextcloudMount()) { + continue; + } + } + $volumeEntry = $volume->name . ':' . $volume->mountPoint; - if($volume->isWritable) { + if ($volume->isWritable) { $volumeEntry = $volumeEntry . ':' . 'rw'; } else { $volumeEntry = $volumeEntry . ':' . 'ro'; @@ -226,7 +233,7 @@ class DockerActionManager 'Image' => $this->BuildImageName($container), ]; - if(count($volumes) > 0) { + if (count($volumes) > 0) { $requestBody['HostConfig']['Binds'] = $volumes; } @@ -447,10 +454,11 @@ class DockerActionManager $requestBody['HostConfig']['SecurityOpt'] = ["apparmor:unconfined"]; } + $mounts = []; + // Special things for the backup container which should not be exposed in the containers.json if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') { // Additional backup directories - $mounts = []; foreach ($this->getAllBackupVolumes() as $additionalBackupVolumes) { if ($additionalBackupVolumes !== '') { $mounts[] = ["Type" => "volume", "Source" => $additionalBackupVolumes, "Target" => "/nextcloud_aio_volumes/" . $additionalBackupVolumes, "ReadOnly" => false]; @@ -465,13 +473,22 @@ class DockerActionManager } } } - if(count($mounts) > 0) { - $requestBody['HostConfig']['Mounts'] = $mounts; - } // Special things for the talk container which should not be exposed in the containers.json } elseif ($container->GetIdentifier() === 'nextcloud-aio-talk') { // This is needed due to a bug in libwebsockets which cannot handle unlimited ulimits $requestBody['HostConfig']['Ulimits'] = [["Name" => "nofile", "Hard" => 200000, "Soft" => 200000]]; + // Special things for the nextcloud container which should not be exposed in the containers.json + } elseif ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') { + foreach ($container->GetVolumes()->GetVolumes() as $volume) { + if ($volume->name !== $this->configurationManager->GetNextcloudMount()) { + continue; + } + $mounts[] = ["Type" => "bind", "Source" => $volume->name, "Target" => $volume->mountPoint, "ReadOnly" => !$volume->isWritable, "Propagation" => "rshared"]; + } + } + + if (count($mounts) > 0) { + $requestBody['HostConfig']['Mounts'] = $mounts; } $url = $this->BuildApiUrl('containers/create?name=' . $container->GetIdentifier());