Installation NextCloud on Debian 12 by Docker Compose

Hi,
I come to you today following the reinstallation of my machine.
Indeed, I am on Debian 12 and encounter a bad setting on my Docker Compose and do not understand how to solve the problem.
Indeed, the docker-compose.yaml file is located in the /docker/ folder.
Since the data on NextCloud is large, I can’t store it on my install disk and therefore want it to be in the disk mounted in /media/disk1/nextcloud/data/
Only, an error message occurs each time.
“ERROR: The volume named “nextcloud:/var/www/html:rw” is used in the service “nextcloud_app” but no statement was found in the volumes section.”
I attach my configuration file, and thank you in advance.

Docker MariaDB
  nextcloud_db:
    image: mariadb
    container_name: MariaDB
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
     - "/docker/MariaDB/:/var/lib/mysql"
    environment:
       # Mot de passe de l'utilisateur root de mariadb
     - MYSQL_ROOT_PASSWORD=$NEXTCLOUD_MYSQL_ROOT_PASSWORD
       # Nom de la base de données à créer à l'initialisation du conteneur
     - MYSQL_DATABASE=$NEXTCLOUD_MYSQL_DATABASE
       # Nom de l'utilisateur de la base de données créée
     - MYSQL_USER=$NEXTCLOUD_MYSQL_USER
       # Mot de passe de l'utilisateur créé
     - MYSQL_PASSWORD=$NEXTCLOUD_MYSQL_PASSWORD
     
#Docker REDIS (cache NEXTCLOUD)
  nextcloud-redis:
    image: redis:latest
    container_name: nextcloud-redis
    hostname: nextcloud-redis
    restart: unless-stopped
    
#Docker NEXTCLOUD 
  nextcloud_app:
    image: nextcloud
    restart: always
    container_name: NEXTCLOUD
    ports:
     - $NEXTCLOUD_PORT:80
    links:
     - nextcloud_db
    depends_on:
     - nextcloud-redis
    volumes:
     - nextcloud:/var/www/html
     - apps:/nextcloud/custom_apps
     - config:/nextcloud/config
     - data:/media/disque1/nextcloud/data
    environment:
       # Nom du conteneur de la base de données
     - MYSQL_HOST=MariaDB
       # Nom de la base de données
     - MYSQL_DATABASE=$NEXTCLOUD_MYSQL_DATABASE
       # Nom de l'utilisateur de la base de données
     - MYSQL_USER=$NEXTCLOUD_MYSQL_USER
       # Mot de passe de l'utilisateur de la base de données
     - MYSQL_PASSWORD=$NEXTCLOUD_MYSQL_PASSWORD
       # Taille maximale de l'upload autorisé sur le serveur
     - NEXTCLOUD_UPLOAD_LIMIT=50G
       # Temps maximal de téléchargement/upload
     - NEXTCLOUD_MAX_TIME=7200
       # Mémoire allouée pour NEXTCLOUD
     - NEXTCLOUD_MEMORY_LIMIT=4196M```

It looks like you have three issues

  1. You have named volumes referenced, but you aren’t declaring them elsewhere in your Compose file. If you take a look at the examples in the README you’ll see the volumes section that you’re missing (in the example it’s near the top)
  2. For your data volume I suspect what you’re trying to do is more conducive to a bind mount rather than a named volume. See below.
  3. Your apps and config volumes paths don’t make sense. The part to the right of the : in their definitions tells Docker where those volumes should appear in the container. Those need to be where NC expects them. If your intention is to use /nextcloud/paths on your Docker host within your container you need to change them to bind mounts, similar to what I’ll suggest for #2 below.

You probably want something more like:


volumes:
  nextcloud:
  db:

services:
  db:
  [...]
  app:
  [...]
    volumes:
     - nextcloud:/var/www/html
     - /nextcloud/custom_apps:/var/www/html/custom_apps
     - /nextcloud/config:/var/www/html/config
     - /media/disque1/nextcloud/data:/var/www/html/data
[...]