Nextcloud17 with postgres backend failed to install

Hi out there,
i have reinstalled my nextcloud setup as docker container with:

  • the official nextcloud image
  • postgress container
  • traefik as reverse proxy

if i start these brand new config with docker compose, i assume, the nextcloud instance will create automaticaly the nextcloud database in the postgres instance… but this not happens…
anyone has an idea what is wrong here…
see below my compose file:

ncloud_db:
image: postgres
container_name: ncloud_db
restart: always
volumes:
- /nextcloud_data/db:/var/lib/postgresql/data
environment:
- POSTGRES_USER=nextcloud
- POSTGRES_DB=nextcloud
- POSTGRES_PASSWORD=Cloud99Rain
labels:
- “traefik.enable=false”

ncloud:
image: nextcloud
container_name: ncloud
depends_on:
ncloud_db:
condition: service_started
links:
- ncloud_db
volumes:
- /nextcloud_data/nextcloud_base:/var/www/html
- /nextcloud_data/config:/var/www/html/config
environment:
- TZ=CET/CET
- NEXTCLOUD_ADMIN_USER=admin
- NEXTCLOUD_ADMIN_PASSWORD=XXXXX
- NEXTCLOUD_TRUSTED_DOMAINS=https://XX.XX.XX
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
- POSTGRES_PASSWORD=XXXXXX
- POSTGRES_HOST=ncloud_db
labels:
- “traefik.backend=ncloud”

i have trunkated the traefik config here, because this is not the problempoint…

if i start with an empty data dir for nextcloud and for postgress… the nextcloud database will not be created… could you have a look at the output from docker-compose up…

Starting traefik …
Recreating ncloud_db …
Recreating ncloud_db
Recreating ncloud_db … done
Recreating ncloud …
Recreating ncloud … done
Attaching to ncloud_db, traefik, ncloud
ncloud_db | The files belonging to this database system will be owned by user “postgres”.
ncloud_db | This user must also own the server process.
ncloud_db |
ncloud_db | The database cluster will be initialized with locale “en_US.utf8”.
ncloud_db | The default database encoding has accordingly been set to “UTF8”.
ncloud_db | The default text search configuration will be set to “english”.
ncloud_db |
ncloud_db | Data page checksums are disabled.
ncloud_db |
ncloud_db | fixing permissions on existing directory /var/lib/postgresql/data … ok
ncloud_db | creating subdirectories … ok
ncloud_db | selecting dynamic shared memory implementation … posix
ncloud_db | selecting default max_connections … 100
ncloud_db | selecting default shared_buffers … 128MB
ncloud_db | selecting default time zone … Etc/UTC
ncloud_db | creating configuration files … ok
ncloud_db | running bootstrap script … ok
ncloud | Initializing nextcloud 17.0.1.1 …
ncloud_db | performing post-bootstrap initialization … ok
ncloud_db | syncing data to disk … initdb: warning: enabling “trust” authentication for local connections
ncloud_db | You can change this by editing pg_hba.conf or using the option -A, or
ncloud_db | --auth-local and --auth-host, the next time you run initdb.
ncloud_db | ok
ncloud_db |
ncloud_db |
ncloud_db | Success. You can now start the database server using:
ncloud_db |
ncloud_db | pg_ctl -D /var/lib/postgresql/data -l logfile start
ncloud_db |
ncloud_db | waiting for server to start…2019-11-29 11:43:38.809 UTC [46] LOG: starting PostgreSQL 12.1 (Debian 12.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
ncloud_db | 2019-11-29 11:43:38.824 UTC [46] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
ncloud_db | 2019-11-29 11:43:39.038 UTC [47] LOG: database system was shut down at 2019-11-29 11:43:36 UTC
ncloud_db | 2019-11-29 11:43:39.101 UTC [46] LOG: database system is ready to accept connections
ncloud_db | done
ncloud_db | server started
ncloud_db | CREATE DATABASE
ncloud_db |
ncloud_db |
ncloud_db | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
ncloud_db |
ncloud_db | 2019-11-29 11:43:40.414 UTC [46] LOG: received fast shutdown request
ncloud_db | waiting for server to shut down…2019-11-29 11:43:40.451 UTC [46] LOG: aborting any active transactions
ncloud_db | 2019-11-29 11:43:40.459 UTC [46] LOG: background worker “logical replication launcher” (PID 53) exited with exit code 1
ncloud_db | 2019-11-29 11:43:40.461 UTC [48] LOG: shutting down
ncloud_db | 2019-11-29 11:43:40.840 UTC [46] LOG: database system is shut down
ncloud_db | done
ncloud_db | server stopped
ncloud_db |
ncloud_db | PostgreSQL init process complete; ready for start up.
ncloud_db |
ncloud_db | 2019-11-29 11:43:41.011 UTC [1] LOG: starting PostgreSQL 12.1 (Debian 12.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
ncloud_db | 2019-11-29 11:43:41.017 UTC [1] LOG: listening on IPv4 address “0.0.0.0”, port 5432
ncloud_db | 2019-11-29 11:43:41.021 UTC [1] LOG: could not create IPv6 socket for address “::”: Address family not supported by protocol
ncloud_db | 2019-11-29 11:43:41.082 UTC [1] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
ncloud_db | 2019-11-29 11:43:41.267 UTC [64] LOG: database system was shut down at 2019-11-29 11:43:40 UTC
ncloud_db | 2019-11-29 11:43:41.321 UTC [1] LOG: database system is ready to accept connections
ncloud | Initializing finished
ncloud | New nextcloud instance
ncloud | Installing with PostgreSQL database
ncloud | starting nextcloud installation
ncloud | An unhandled exception has been thrown:
ncloud | PDOException: SQLSTATE[HY000]: General error: 1 no such table: oc_appconfig in /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:88
ncloud | Stack trace:
ncloud | #0 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(88): PDO->query(‘SELECT * FROM "…’)
ncloud | #1 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(908): Doctrine\DBAL\Driver\PDOConnection->query(‘SELECT * FROM "…’)
ncloud | #2 /var/www/html/lib/private/DB/Connection.php(195): Doctrine\DBAL\Connection->executeQuery(‘SELECT * FROM "…’, Array, Array, NULL)
ncloud | #3 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery(‘SELECT * FROM "…’, Array, Array)
ncloud | #4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(214): Doctrine\DBAL\Query\QueryBuilder->execute()
ncloud | #5 /var/www/html/lib/private/AppConfig.php(329): OC\DB\QueryBuilder\QueryBuilder->execute()
ncloud | #6 /var/www/html/lib/private/AppConfig.php(107): OC\AppConfig->loadConfigValues()
ncloud | #7 /var/www/html/lib/private/AppConfig.php(285): OC\AppConfig->getApps()
ncloud | #8 /var/www/html/lib/private/legacy/app.php(880): OC\AppConfig->getValues(false, ‘installed_versi…’)
ncloud | #9 /var/www/html/lib/private/Server.php(503): OC_App::getAppVersions()
ncloud | #10 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
ncloud | #11 /var/www/html/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet(‘OC\Memcache\Fac…’)
ncloud | #12 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(161): OC\ServerContainer->query(‘OC\Memcache\Fac…’)
ncloud | #13 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))

this looks for me as the nextcloud server tries to do select statements on tabels which does not exist.
The nextcloud.log is empty at this moment.

i have tried the same with mariadb… and i got similar failures…
i assume i am wrong with
anyone any ideas…

regards uwe

try:

environment:
  - POSTGRES_USER=nextcloud
  - POSTGRES_DB=default
  - POSTGRES_PASSWORD=Cloud99Rain

the nextcloud setup script will create the database nextcloud on first startup. but it will fail if that database is already created by the postgres container.

so don’t change the following to default. then you have the same problem again.

Hi Reiner,
thanks for the hint… now it runs like a charm :slight_smile:

I think it would be usefull to put that hint in the description on docker-hub…

best regards Uwe

It’s on GitHub. So do a merge request. :wink: