docker icon indicating copy to clipboard operation
docker copied to clipboard

POSTGRES_* are ignored when NEXTCLOUD_ADMIN_* are omitted.

Open raldone01 opened this issue 5 years ago • 3 comments

What is happening?

The postgresql database configuration values are ignored.

What should happen?

The postgresql database configuration should be used.

Setup

Docu:

If you set any values, they will not be asked in the install page on first run. With a complete configuration by using all variables for your database type, you can additionally configure your Nextcloud instance by setting admin user and password (only works if you set both):
    NEXTCLOUD_ADMIN_USER Name of the Nextcloud admin user.
    NEXTCLOUD_ADMIN_PASSWORD Password for the Nextcloud admin user.

Example docker-compose: (I omitted my reverse proxy)

version: '3.2'
services:
    nextcloud-db:
        image: postgres
        restart: unless-stopped
        volumes:
         - ${CONTAINERP}/nextcloud-db:/var/lib/postgresql/data
        environment:
         - POSTGRES_DB_FILE=/run/secrets/postgres_db
         - POSTGRES_USER_FILE=/run/secrets/postgres_user
         - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
        secrets:
         - postgres_db
         - postgres_password
         - postgres_user
        networks:
         - back-nextcloud
    nextcloud:
        restart: unless-stopped
        image: nextcloud
        volumes:
         - ${CONTAINERP}/nextcloud/nextcloud:/var/www/html
         - ${CONTAINERP}/nextcloud/apps:/var/www/html/custom_apps
         - ${CONTAINERP}/nextcloud/config:/var/www/html/config
         - ${CONTAINERP}/nextcloud/data:/var/www/html/data
        environment:
          - POSTGRES_HOST=nextcloud-db
          - POSTGRES_DB_FILE=/run/secrets/postgres_db
          - POSTGRES_USER_FILE=/run/secrets/postgres_user
          - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
#          - NEXTCLOUD_ADMIN_PASSWORD=pwd # REQUIRED?
#          - NEXTCLOUD_ADMIN_USER=admin
        secrets:
         - postgres_db
         - postgres_password
         - postgres_user
        ports:
         - 8080:80
        networks:
         - front
         - back-nextcloud
        depends_on:
         - nextcloud-db
networks:
    front:
    back-nextcloud:
secrets:
  postgres_db:
    file: ./secrets/postgres_db.txt # put postgresql db name to this file
  postgres_password:
    file: ./secrets/postgres_password.txt # put postgresql password to this file
  postgres_user:
    file: ./secrets/postgres_user.txt # put postgresql username to this file

Repository to reproduce.

raldone01 avatar Aug 29 '20 15:08 raldone01

Interesting... I can confirm this! Usually autoconfig.php should handle this, but as you did not configure the Postgresconfig via the "normal" var, but instead used the secrets autoconfig did not work. The fix should be easy though... 😅

dermalikmann avatar Oct 06 '20 16:10 dermalikmann

The documentation is wrong, it says to write the env variables:

  • POSTGRES_DB_FILE
  • POSTGRES_USER_FILE
  • POSTGRES_PASSWORD_FIL However if yous search on the repository, those env strings are never used (only on the README.md). https://github.com/nextcloud/docker/search?q=POSTGRES_USER_FILE

You should use this env variables instead:

  • POSTGRES_DB
  • POSTGRES_USER
  • POSTGRES_PASSWORD

BorjaEst avatar Oct 19 '20 13:10 BorjaEst

It depends whether you use a docker secret or a env: https://github.com/nextcloud/docker/blob/65634abac63693c073d85842e0585c6b94be2c48/docker-entrypoint.sh#L22-L44

I guess the docs are a bit misleading here. The auto configuration is only working if a admin user and database is configured. https://github.com/nextcloud/docker/blob/65634abac63693c073d85842e0585c6b94be2c48/docker-entrypoint.sh#L115

J0WI avatar Nov 07 '20 01:11 J0WI

This will further clarified in the docs via #2224 so closing.

joshtrichards avatar Oct 14 '24 22:10 joshtrichards