Jump to content

Hello guys. I was working through making a database portainer stack and I got it up and running. I wanted to attach the databases to a nextcloud deployment but I’m running into issues. This is the portainer stack for the databases. 

services: 
 db-mariadb:
   image: mariadb
   container_name: mariadb
   command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
   privileged: true
   environment:
     MARIADB_USER: xxx
     MARIADB_PASSWORD: xxx
     MARIADB_DATABASE: xxx
     PUID: xxx
     PGID: xxx
   ports:
     - "3306:3306"
   volumes:
     - /database/MariaDB:/var/lib/mysql:rw
   networks:
     - mysql

 db-postgresdb:
   image: postgres
   container_name: postgres
   privileged: true
   environment:
     POSTGRES_USER: xxx
     POSTGRES_PASSWORD: xxx
     POSTGRES_DB: xxx
     PUID: xxx
     PGID: xxx
   ports:
     - "5432:5432"
   volumes:
     - /database/PostgresDB:/var/lib/postgresql/data:rw
   networks:
     - mysql
     
 db-redisdb:
   image: redis
   container_name: redis
   restart: always
   command: redis-server --save 20 1 --loglevel warning --requirepass xxx
   privileged: true
   ports:
     - "6379:6379"
   volumes:
     - /database/RedisDB:/data:rw
   networks:
     - mysql
     
 db-adminerdb:
   container_name: adminer
   image: adminer
   restart: always
   ports:
     - "8080:8080"
   networks:
     - mysql

networks:
 mysql:
   external: true

This is the stack for the nextcloud deployment.

services:
  nextcloud:
    image: nextcloud:apache
    restart: always
    ports:
      - 8910:80
    volumes:
      - /mnt/xxxxxx/xxxxxx/appdata/nextcloud:/var/www/html
    networks:
      - mysql
    environment:
      - REDIS_HOST= xxx.xxx.xxx.xxx:6379
      - MARIADB_HOST= xxx.xxx.xxx.xxx:3306
      - MARIADB_DATABASE= xxx
      - MARIADB_USER= xxx
      - MARIADB_PASSWORD= xxx

networks:
  mysql:
    external: true

When I connect the nextcloud page I get an internal server error. When I check portainer for the logs. I get only 4 lines.

Configuring Redis as session handler 
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.6. Set the 'ServerName' directive globally to suppress this message 
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.6. Set the 'ServerName' directive globally to suppress this message 
[Fri Jun 23 02:22:11.696544 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.56 (Debian) PHP/8.2.7 configured -- resuming normal operations

What did I do wrong? How can I correctly add the existing database to the portainer stack. Thanks for the help. Have a good day.

Link to comment
https://linustechtips.com/topic/1515005-help-with-dockerized-database/
Share on other sites

Link to post
Share on other sites

Those log lines you're getting are very generic Apache Nextcloud log lines. Not indicating problems.

 

The log file you're looking for is a file named nextcloud.log under your data directory, wherever that lives. See also the logging docs: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/logging_configuration.html

 

However, without further info what this looks like to me is that you're addressing your database wrong. You specify:

      - MARIADB_HOST= xxx.xxx.xxx.xxx:3306

What IP address are you using? You mariadb container will get a random IP address in the `mysql` network when you spin it up. I'm guessing you specified the IP address of the host you're running, which will not be exposing this service on its physical TCP stack.

 

I've never worked with portainer though, so I'm just going off of the docker-swarm knowledge I have seeing as the config you showed seems to be compatible with that. I also don't see how you're spinning up that `mysql` network. Is it a simple `docker network create` with type overlay?

Link to post
Share on other sites

Also, you're going to want to use some sort of secret management for those DB passwords so they're not just sitting there plaintext. Never worked with portainer but according to their docs (https://docs.portainer.io/user/docker/secrets) they're simply using Docker Swarm underlying with Docker Swarm secret management. Given that that's the case, I'll attach my Docker Swarm Nextcloud setup.

 

You'll see it puts all persistent data on a zfspool, as well as it uses a Docker Swarm Secret for the DB password. I don't use env vars for settings for Nextcloud, as that allowed me to go through the nice initial setup page in the beginning and set up the DB schema through the web UI in Nextcloud.

 

Further, you'll see it uses Traefik to expose my stuff to the outside world, as well as handle TLS offloading and certificate management with let's encrypt.

 

Lastly, it uses some Swarm cronjobs to perform regular maintenance tasks.

 

All that said though, if you're just starting out right now, do yourself a favor and do not use Docker Swarm. It's pretty damn obsolete as it's not maintained by Docker anymore. I'd try to standardize on some Kubernetes-based system instead. My stack was set up like this when Docker Swarm was still somewhat relevant years ago but I made the wrong call then and should've jumped on the k8s train. Hindsight 20/20.

nextcloud.yml

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×