Externer Speicher mit Docker freigeben

config.php:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'upgrade.disable-web' => true,
  'instanceid' => 'instanceid',
  'passwordsalt' => 'passwordsalt',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => 'ip:8080',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '30.0.0.14',
  'overwrite.cli.url' => 'http://ip:8080',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'dbpassword',
  'installed' => true,
);

docker-compose.yml:

volumes:
  nextcloud:
  db:
  share:
    external: true

services:
  db:
    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=MYSQL_ROOT_PASSWORDMRPq
      - MYSQL_PASSWORD=MYSQL_PASSWORD
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
      - share:/share
    environment:
      - MYSQL_PASSWORD=gPRKTaEIZTbdellwD3WY
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

Ich möchte auf den Ordner /share sowohl normal über Ubuntu, als auch über Nextcloud mit der Funktion Externer Speicher zugreifen.

Ich habe es gelöst, in dem ich den Befehl mount --bind /share /var/lib/docker/volumes/share/_data automatisch beim Hochfahren meines Servers ausführen lasse.

Mittlerweile funktioniert es nicht mehr. Wenn ich die Dateien unter

volumes:
      - share:/share

einbinde, bekomme ich den Fehler angezeigt:
Das Verzeichnis ist nicht verfügbar, bitte die Logdateien überprüfen oder Administrator kontaktieren.

Wenn ich sie unter

volumes:
      - share:/var/www/html/share

einbinde, werden mir die Ordner in der files App nicht angezeigt.
Wenn ich dann links auf externen Speicher klicke und einen Ordner auswähle, wird mir angezeigt:
Ordner nicht gefunden.

In den Verwaltungseinstellungen unter Externer Speicher werden mir in beiden Fällen keine Fehler angezeigt.

Ich habe auch nachgeschaut, ob die Dateien im Nextcloud Docker auch wirklich vorhanden sind und ja sind sie.

Liegt es vielleicht daran, dass die Gruppe dieser Dateien users ist und nur der Benutzer www-data?

Ich habe auch versucht mit occ files:scan sie zu finden, aber ohne Glück, da scheinbar nur nach usern gesucht werden kann.

also ich weiß nicht ob ich das alles richtig nachvollzogen habe, jedoch fällt mir eines auf

volumes:
  - nextcloud:/var/www/html
  - share:/share

deine Ordner liegen aber beide unter /var/www/html ?

Wenn ich sie unter

volumes:
      - share:/var/www/html/share

was ist dieser share Ordner? sprich liegt der lokal und du willst den in die nc mounten oder liegt der in der nc und du willst den lokal mounten?

Ich habe testweise mal beides ausprobiert. Mal unter
/share
und mal unter
/var/www/html/share
Bei beiden Methoden hatte ich unterschiedliche Ergebnisse in meiner Nextcloud.

Dieser /share Ordner ist bei meinem Ubuntu Server der Ort, an dem auch mein samba Server eingerichtet ist. Also alle Dateien, die ich über das lokale Netzwerk auf den Server schiebe, landen hier.

Ich habe in Docker ein share volume angelegt und danach meinen lokalen /share Ordner auf dieses volume gemountet.

In der Nextcloud sind konnte ich diese Ordner ohne Probleme einbinden und sie sind auch immer sichtbar, aber leider werden keine Dateien oder Ordner innen angezeigt.

occ files:scan für diesen Ordner ausgeführt, das ist ein extern angebundenes Filesystem, NC bekommt Änderungen auf Dateiebene nicht aktiv mit und muss daher “manuell” eingelesen werden.

das funktioniert nur dann, wenn im Docker Container und dem verwendeten Ordner auch Inhalte angezeigt werden, wenn das nicht so ist, wird der files scan nicht helfen, dass muss vorab sichergestellt sein, dass der mnt sauber funktioniert und die Daten auch enthält.

Ich habe schon mal in das Verzeichnis von der Nextcloud reingeschaut und die alle Dateien waren eingebunden.

Funktioniert occ files:scan --all auch für externe Verzeichnisse?

ja.
Muss aber in einem Job verankert werden, zu min. ist es bei meiner native Installation so, dieser Befehl muss für die “externen” Ordner immer wieder durchgeführt werden, daher würde ich den Befehl auf den jeweiligen Ordner beschränken.

Ich habe jetzt noch einmal occ files:scan --all durchgeführt und es kam zu folgender Meldung:

Starting scan for user 1 out of 6 (user1)
Exception during scan: No such file or directory
#0 /var/www/html/lib/private/RedisFactory.php(104): Redis->pconnect('/var/run/redis/...', 0, 0.0, NULL, 0, 0.0)
#1 /var/www/html/lib/private/RedisFactory.php(148): OC\RedisFactory->create()
#2 /var/www/html/lib/private/Memcache/Redis.php(53): OC\RedisFactory->getInstance()
#3 /var/www/html/lib/private/Memcache/Redis.php(117): OC\Memcache\Redis->getCache()
#4 /var/www/html/lib/private/Lock/MemcacheLockingProvider.php(73): OC\Memcache\Redis->add('files/e8482945c...', '0')
#5 /var/www/html/lib/private/Files/Storage/Common.php(640): OC\Lock\MemcacheLockingProvider->acquireLock('files/e8482945c...', 2, 'home::user1::sc...')
#6 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Common->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#7 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#8 /var/www/html/lib/private/Files/Cache/Scanner.php(315): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#9 /var/www/html/lib/private/Files/Utils/Scanner.php(263): OC\Files\Cache\Scanner->scan('', true, 3)
#10 /var/www/html/apps/files/lib/Command/Scan.php(154): OC\Files\Utils\Scanner->scan('/user1', true, NULL)
#11 /var/www/html/apps/files/lib/Command/Scan.php(215): OCA\Files\Command\Scan->scanFiles('user1', '/user1', NULL, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#12 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/3rdparty/symfony/console/Application.php(1078): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#19 /var/www/html/occ(33): require_once('/var/www/html/c...')
#20 {main}
Starting scan for user 2 out of 6 (user2)
Exception during scan: Redis server went away
#0 /var/www/html/lib/private/Memcache/Redis.php(117): Redis->set('e3f11b1656833fe...', '0', Array)
#1 /var/www/html/lib/private/Lock/MemcacheLockingProvider.php(73): OC\Memcache\Redis->add('files/cfa45693a...', '0')
#2 /var/www/html/lib/private/Files/Storage/Common.php(640): OC\Lock\MemcacheLockingProvider->acquireLock('files/cfa45693a...', 2, 'home::user2::sca...')
#3 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Common->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#4 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#5 /var/www/html/lib/private/Files/Cache/Scanner.php(315): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#6 /var/www/html/lib/private/Files/Utils/Scanner.php(263): OC\Files\Cache\Scanner->scan('', true, 3)
#7 /var/www/html/apps/files/lib/Command/Scan.php(154): OC\Files\Utils\Scanner->scan('/user2', true, NULL)
#8 /var/www/html/apps/files/lib/Command/Scan.php(215): OCA\Files\Command\Scan->scanFiles('user2', '/user2', NULL, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#9 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/3rdparty/symfony/console/Application.php(1078): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#16 /var/www/html/occ(33): require_once('/var/www/html/c...')
#17 {main}
Starting scan for user 3 out of 6 (user3)
Exception during scan: Redis server went away
#0 /var/www/html/lib/private/Memcache/Redis.php(117): Redis->set('e3f11b1656833fe...', '0', Array)
#1 /var/www/html/lib/private/Lock/MemcacheLockingProvider.php(73): OC\Memcache\Redis->add('files/7a42a2124...', '0')
#2 /var/www/html/lib/private/Files/Storage/Common.php(640): OC\Lock\MemcacheLockingProvider->acquireLock('files/7a42a2124...', 2, 'home::user3::s...')
#3 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Common->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#4 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#5 /var/www/html/lib/private/Files/Cache/Scanner.php(315): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#6 /var/www/html/lib/private/Files/Utils/Scanner.php(263): OC\Files\Cache\Scanner->scan('', true, 3)
#7 /var/www/html/apps/files/lib/Command/Scan.php(154): OC\Files\Utils\Scanner->scan('/user3', true, NULL)
#8 /var/www/html/apps/files/lib/Command/Scan.php(215): OCA\Files\Command\Scan->scanFiles('user3', '/user3', NULL, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#9 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/3rdparty/symfony/console/Application.php(1078): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#16 /var/www/html/occ(33): require_once('/var/www/html/c...')
#17 {main}
Starting scan for user 4 out of 6 (user4)
Exception during scan: Redis server went away
#0 /var/www/html/lib/private/Memcache/Redis.php(117): Redis->set('e3f11b1656833fe...', '0', Array)
#1 /var/www/html/lib/private/Lock/MemcacheLockingProvider.php(73): OC\Memcache\Redis->add('files/91c4a9789...', '0')
#2 /var/www/html/lib/private/Files/Storage/Common.php(640): OC\Lock\MemcacheLockingProvider->acquireLock('files/91c4a9789...', 2, 'home::user4::s...')
#3 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Common->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#4 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#5 /var/www/html/lib/private/Files/Cache/Scanner.php(315): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#6 /var/www/html/lib/private/Files/Utils/Scanner.php(263): OC\Files\Cache\Scanner->scan('', true, 3)
#7 /var/www/html/apps/files/lib/Command/Scan.php(154): OC\Files\Utils\Scanner->scan('/user4', true, NULL)
#8 /var/www/html/apps/files/lib/Command/Scan.php(215): OCA\Files\Command\Scan->scanFiles('user4', '/user4', NULL, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#9 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/3rdparty/symfony/console/Application.php(1078): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#16 /var/www/html/occ(33): require_once('/var/www/html/c...')
#17 {main}
Starting scan for user 5 out of 6 (user5)
Exception during scan: Redis server went away
#0 /var/www/html/lib/private/Memcache/Redis.php(117): Redis->set('e3f11b1656833fe...', '0', Array)
#1 /var/www/html/lib/private/Lock/MemcacheLockingProvider.php(73): OC\Memcache\Redis->add('files/e5dd96e3e...', '0')
#2 /var/www/html/lib/private/Files/Storage/Common.php(640): OC\Lock\MemcacheLockingProvider->acquireLock('files/e5dd96e3e...', 2, 'home::user5:...')
#3 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Common->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#4 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(298): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#5 /var/www/html/lib/private/Files/Cache/Scanner.php(315): OC\Files\Storage\Wrapper\Wrapper->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))
#6 /var/www/html/lib/private/Files/Utils/Scanner.php(263): OC\Files\Cache\Scanner->scan('', true, 3)
#7 /var/www/html/apps/files/lib/Command/Scan.php(154): OC\Files\Utils\Scanner->scan('/user5', true, NULL)
#8 /var/www/html/apps/files/lib/Command/Scan.php(215): OCA\Files\Command\Scan->scanFiles('user5', '/user5', NULL, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#9 /var/www/html/3rdparty/symfony/console/Command/Command.php(326): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/3rdparty/symfony/console/Application.php(1078): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#16 /var/www/html/occ(33): require_once('/var/www/html/c...')
#17 {main}
Starting scan for user 6 out of 6 (user6)
+---------+-------+-----+---------+---------+--------+--------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
+---------+-------+-----+---------+---------+--------+--------------+
| 0       | 0     | 0   | 0       | 0       | 5      | 00:00:00     |
+---------+-------+-----+---------+---------+--------+--------------+

Die Benutzer habe ich umbenannt in user1 bis user6.

dein Redis Server reagiert nicht wie er soll