docker-composenginx-reverse-proxynextcloud

Custom installation of docker nextcloud


I'm trying to configure my nextcloud on my digitalocean server (debian 11). Using nginx proxy manager and nextcloud under docker

  1. I change the root directory of the docker-compose (since I was out of disk space, I added a volume and mounted it at /var/lib/docker/volumes/volume_nyc1_01)
  2. I created a new folder called nextcloud. Inside that created docker-co

Version: "3"
volumes:
 nextcloud-data:
 nextcloud-db:
 npm-data:
 npm-ssl:
 npm-db:

networks:
 frontend:
   # add this if the network is already existing!
   # external: true
 backend:

services:
 nextcloud-app:
   image: nextcloud
   restart: always
   volumes:
     - nextcloud-data:/var/lib/docker/volumes/volume_nyc1_01/var/www/html
   environment:
     - MYSQL_PASSWORD=raspberrypi
     - MYSQL_DATABASE=nextcloud
     - MYSQL_USER=nextcloud
     - MYSQL_HOST=nextcloud-db
   networks:
     - frontend
     - backend

 nextcloud-db:
   image: mariadb
   restart: always
   command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
   volumes:
     - nextcloud-db:/var/lib/docker/volumes/volume_nyc1_01/var/lib/mysql
  environment:
     - MYSQL_ROOT_PASSWORD=raspberrypi
     - MYSQL_PASSWORD=raspberrypi
     - MYSQL_DATABASE=nextcloud
     - MYSQL_USER=nextcloud
   networks:
     - backend

 npm-app:
   image: jc21/nginx-proxy-manager:latest
   restart: always
   ports:
     - "80:80"
     - "81:81"
     - "443:443"
   environment:
     - DB_MYSQL_HOST=npm-db
     - DB_MYSQL_PORT=3306
     - DB_MYSQL_USER=npm
     - DB_MYSQL_PASSWORD=raspberrypi
     - DB_MYSQL_NAME=npm
   volumes:
     - npm-data:/var/lib/docker/volumes/volume_nyc1_01/data
     - npm-ssl:/var/lib/docker/volumes/volume_nyc1_01/etc/letsencrypt
   networks:
     - frontend
     - backend

 npm-db:
   image: jc21/mariadb-aria:latest
   restart: always
   environment:
     - MYSQL_ROOT_PASSWORD=raspberrypi
     - MYSQL_DATABASE=npm
     - MYSQL_USER=npm
     - MYSQL_PASSWORD=raspberrypi
   volumes:
     - npm-db:/var/lib/docker/volumes/volume_nyc1_01/var/lib/mysql
   networks:
     - backend


  1. As you could notice, I created through mkdir, each folder after volume_nyc1_01.
  2. Finally I started the server, from /var/lib/docker/volumes/volume_nyc1_01/nextcloud, using docker-compose up -d
  3. Once logged in the ip-addres-server:81, I created the proxy host with domain name mydomain.com and forward hostname/ip nextcloud-app port 80. Saved
  4. When i check in the domain name, it just doesn't show anything. The same happens when tried to establish the ssl.

I know I'm missing something, but I searched a lot and couldn't find anything. I really appreciate any help or suggestion


Solution

  • You seem to be mixing up the volume specification in every container (e.g. nextcloud-data:/var/lib/docker/volumes/volume_nyc1_01/var/www/html and nextcloud-db:/var/lib/docker/volumes/volume_nyc1_01/var/lib/mysql).

    Docker expects that you specify that as docker_volume_name:/path/to/folder/in/container, in the case of nextcloud-app container that would be: nextcloud:/var/www/html.
    Similarly other containers should map the volume to the correct folder inside the container.

    The /var/lib/docker/volumes/volume_nyc1_01 location is on the docker host (the machine running all the containers) and has no place in those volume specification lines.

    If you want to store your docker volumes, images, containers, etc... in another location on the host machine (e.g. to manage disk space) you need to configure and relocate the docker data-root directory. This guide from IBM shows how, but there are plenty other guides you can find online.