As another option, I set up nextcloud with the nextcloud:latest image, rather than the very complex and cumbersome (IMHO!) AIO image, which seems to create all sorts of containers and dependencies on its own.
My compose file (for deployment in Dockge), which uses host mounts, is as follows:
services:
db:
image: mariadb:10.6
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
restart: unless-stopped
volumes:
- ./db:/var/lib/mysql:Z
environment:
- MYSQL_ROOT_PASSWORD=changeme
- MARIADB_AUTO_UPGRADE=1
- MARIADB_DISABLE_UPGRADE_BACKUP=1
env_file:
- db.env
redis:
image: redis:alpine
restart: unless-stopped
app:
build:
dockerfile: ./dockerfile
restart: unless-stopped
ports:
- 192.168.1.5:8089:80
volumes:
- ./nextcloud:/var/www/html:z
environment:
- MYSQL_HOST=db
- REDIS_HOST=redis
- PHP_MEMORY_LIMIT=1024M
- PHP_UPLOAD_LIMIT=1024M
env_file:
- db.env
depends_on:
- db
- redis
cron:
image: docker.io/library/nextcloud:latest
restart: unless-stopped
volumes:
- ./nextcloud:/var/www/html:z
entrypoint: /cron.sh
depends_on:
- db
- redis
volumes:
db: null
nextcloud: null
networks: {}
(obviously adjust password and IP:ports to suit your setup.
In terms of files in my nextcloud, I mount a SMB share (which I’ve set up on TrueNAS) as a network share.
This means instead of a dedicated data folder hidden away, I simply point nextcloud at a network share.
Most nextcloud images I’ve seen (including the official docker non-AIO image) need to have SMB functionality added, which means I use a dockerfile to add SMB functionality to the nextcloud:latest image. If you use NFS, I don’t think this is needed.
The dockerfile (referred to in the compose file above) is:
FROM nextcloud:latest
RUN apt update && apt install -y smbclient libsmbclient-dev nano sudo && rm -rf /var/lib/apt/lists/*
RUN pecl install smbclient
RUN docker-php-ext-enable smbclient
Then, once in your nextcloud web GUI, go to “Administration settings > External storage” and enter the details for your network share you want to access.
TLDR; using this approach, you don’t have to worry about migrating or losing your nextcloud data (unless your SMB/NFS share goes kaput!).