Mount optional storage to nextcloud docker

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Sorry if any information is missing but I am new at this. I bought a Raspberry Pi and I am trying to run Nextcloud on it with my external HDD.

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 32.0.0
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian GNU/Linux 12
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.65
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • None
  • PHP version (e.g, 8.3):
    • 8.3.26
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • after creating Dockerfile
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Docker
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • Cloudflare tunnel

Summary of the issue you are facing:

I have created a DockerFile, which I build and then executed with docker-compose

Dockerfile:

rishiakpi@rishiakpi:\~/Desktop/nextcloud $ cat Dockerfile
FROM nextcloud:latest
RUN apt-get update && apt-get install -y --no-install-recommends 
imagemagick 
ffmpeg 
libreoffice 
&& rm -rf /var/lib/apt/lists/\*

docker-compose.yml

rishiakpi@rishiakpi:~/Desktop/nextcloud $ cat docker-compose.yml 
services:
  db:
    image: mariadb
    container_name: nextcloud_db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: XXXXX
      MYSQL_DATABASE: XXXXX
      MYSQL_USER: XXXXX
      MYSQL_PASSWORD: XXXXX
    volumes:
      - db_data:/var/lib/mysql

  app:
    build: .
    container_name: nextcloud_app
    ports:
      - "3002:80"
    restart: always
    environment:
      MYSQL_PASSWORD: XXXXX
      MYSQL_DATABASE: XXXXX
      MYSQL_USER: XXXXXX
      MYSQL_HOST: XXXX
    volumes:
      - ~/Desktop/nextcloud/dockerdata:/var/www/html
      - /mnt:/disks
    depends_on:
      - db

volumes:
  db_data:

HDD mounting

I have set in my /etc/fstab to mount the drives like this

rishiakpi@rishiakpi:~/Desktop/nextcloud $ cat /etc/fstab 
proc            /proc           proc    defaults          0       0
PARTUUID=da4981d2-01  /boot/firmware  vfat    defaults          0       2
PARTUUID=da4981d2-02  /               ext4    defaults,noatime  0       1
UUID=4E1A898A1A896FAF  /mnt/myhdd  ntfs-3g  defaults,nofail,x-systemd.device-timeout=15,x-systemd.automount,noatime  0  0
UUID=645317be-958b-415a-9c28-52bfb91638f2 /mnt/myhdd2 ext4 defaults,noatime,nofail,x-systemd.device-timeout=15,x-systemd.automount 0 0
UUID=2ED6E5939B54CF17 /mnt/ivkahdd ntfs-3g defaults,nofail,x-systemd.device-timeout=15,x-systemd.automount,noatime 0 0

External folders

Problem

When I run docker-compose up -d my nextcloud works normally, I mounted external folders and I can go to /disks/myhdd for example in nextcloud bash. The problem occurs when I reboot the PI. Nextcloud should start automatically, everything loads and when I open nextcloud, I cant access my external folders. When I open nextcloud bash and try to navigate to the folder, for example /disks/myhdd i get Too many levels of symbolic links.
When I use docker restart nextcloud_app, it works. My question is, is there a possibility to mount my external HDDs to nextcloud so I won’t have to restart the container after every reboot? I don’t want to mount them each manually, because sometimes they wont be plugged in and nextcloud won’t start if I explicitly mount them in docker-compose and they are not plugged in. I also set enable sharing and previews on my external folders.

So my question is:
Is there a way to set this up so nextcloud starts on boot and has access to those HDDs, which are plugged in without failing because some of them may not be plugged in without the need to restart the container manually? Or am I doing something wrong?

I tried uploading a test file (20kB) and it took about a minute, before I was uploading 300MB in seconds.. The upload speed is wrong. I was wondering if the problem isn’t in Nextcloud 32 because before I created an image of Nextcloud 29.x.x I don’t know exactly and I wanted previews of videos so I created Dockerfile and created a new image with persistent preview tools and that’s when I went from 29 to 32 and the problem with mounting and now it seems with upload started.

rollback to nextcloud 29 didnt help