Docker based Deployment with Network Attached Storage

I want to deploy Nextcloud using the community docker image (fpm) such that the main data, config and custom_apps directories are stored on a network attached / mounted storage. Here is the docker-compose.yml file:

services:
  db:
    image: mariadb:11.1.2
    …
    networks:
    - nextcloud

  app:
    image: nextcloud:27.1.3-fpm
    restart: always
    volumes:
    - nc_root:/var/www/html
    - /mnt/nextcloud/nextcloud/nc_data:/var/www/html/data
    - /mnt/nextcloud/nextcloud/nc_config:/var/www/html/config
    - /mnt/nextcloud/nextcloud/nc_apps:/var/www/html/custom_apps
    networks:
    - nextcloud

  web:
    image: nginx:1.25
    restart: always
    ports:
    - 80:80
    - 443:443
    volumes:
    - nc_root:/var/www/html
    - /mnt/nextcloud/nextcloud/nc_data:/var/www/html/data
    - /mnt/nextcloud/nextcloud/nc_config:/var/www/html/config
    - /mnt/nextcloud/nextcloud/nc_apps:/var/www/html/custom_apps
    
    networks:
    - nextcloud

Right now /mnt/nextcloud/nextcloud is an ordinary directory on an ordinary device which is ordinarily mounted - I guess its an ext4 filesystem.

WHAT I WANT TO DO: mount -t davfs https:… /mnt/nextcloud/… such that all the data that is produced by Nextcloud - in best case including the database data - is finally located on the File Server.

I have tried that already, but it didn’t work because:

  • the database didn’t start cause of permission errors
  • without the database data directory mounted I got a lot of 404 s especially for stuff comoing from custom_apps/* like icons and so forth.

Is there any resource link, how to, best practice or alike that explains a setup similiar to that one? My Goal is to keep the data off the application server. But the problem is, that the Fileserver is not on the same LAN / Network, so all the files travel the www. The connection is OK, so some latency my occur and would be acceptable.

Thanks for Help!

This could be done but I strongly recommend you not to do this. Nextcloud is designed with an assumption storage and database live close together (like every other similar application). In case your storage becomes unavailable (or maybe “shaky” in terms of access speed/timing) this will result in unpredictable errors which very very very hard to troubleshoot.

I recall some discussions regarding S3 as primary storage - use search for details - but even if you do so - place your application and primary storage close to each other using very reliable connection.

Object storage can be locally hosted with minio

1 Like

Thanks a lot For the replies here! As it turns out, its not the best Idea I have planned here. I’ll better go for a different solution.

I do this over an nfs share but my boxes are sitting next to each other with a 10gb DAC link, not over a wan. It worked ok with a regular local 1gb nic but did have some very slight latency, over a wan youre gonna have a bad time unless ya got a big pipe.