[resoved] `postgres` default database name at intallation (docker image)

Hi,

I’im sorry my english is not good, but i’im going to try to make with.

I’im trying to install Nexcloud 14 with the Docker image. I use Postgresql database.

The installer does not reach has to connect to the database.

When i investigated , i modified the file 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php in public function connect() i had add before $this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions); :

var_dump($user);
var_dump($password);
var_dump($this->_params);

I run php occ maintenance:install -vvv --database pgsql --database-name titi --database-user toto --database-pass ctotoki --database-host db and i obtain :

What is the password you like to use for the admin account <admin>?                                                                                                                      
string(4) "toto"                                                                                                                                                                         
string(7) "ctotoki"                                                                                                                                                                      
array(8) {                                                                                                                                                                               
  ["adapter"]=>                                                                                                                                                                          
  string(18) "OC\DB\AdapterPgSql"                                                                                                                                                        
  ["driver"]=>                                                                                                                                                                           
  string(9) "pdo_pgsql"                                                                                                                                                                  
  ["wrapperClass"]=>                                                                                                                                                                     
  string(16) "OC\DB\Connection"                                                                                                                                                          
  ["host"]=>
  string(2) "db"
  ["user"]=>
  string(4) "toto"
  ["password"]=>
  string(7) "ctotoki"
  ["tablePrefix"]=>
  string(3) "oc_"
  ["dbname"]=>
  string(8) "postgres"
}
string(10) "oc_admin22"
string(30) "f2p54lk83t7zi08rsusz9gj1lqr6yh"
array(8) {
  ["adapter"]=>
  string(18) "OC\DB\AdapterPgSql"
  ["driver"]=>
  string(9) "pdo_pgsql"
  ["wrapperClass"]=>
  string(16) "OC\DB\Connection"
  ["host"]=>
  string(2) "db"
  ["user"]=>
  string(10) "oc_admin22"
  ["password"]=>
  string(30) "f2p54lk83t7zi08rsusz9gj1lqr6yh"
  ["tablePrefix"]=>
  string(3) "oc_"
  ["dbname"]=>
  string(4) "titi"
}
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] FATAL:  permission denied for database "titi"
DETAIL:  User does not have CONNECT privilege.

Why in the fisrt try it dont set $this->_params["dbname"] whith titi value although i supply him the --database-name titi param ?

when i start the postgres docker container i create an admin user with an initial db named default

when i run the occ maintenance:install command i set --database-name nextcloud

when i used twice the same name it didn’t work.

The solution is stupid…

Now for nextcloud installation don’t pre-create nextcoud database (don’t use POSTGRES_DB env variable for postgres container). The nextcoud installater must create the database.

Example docker-compose.yml :

version: '2'

services:
  postgres:
    image: postgres
    environment:
      - POSTGRES_PASSWORD=mypasswd
      - POSTGRES_USER=postgres
  nextcloud:
    image: nextcloud:fpm
    environment:
      - POSTGRES_PASSWORD=mypasswd
      - POSTGRES_USER=postgres
      - POSTGRES_DB=nextcloud
      - POSTGRES_HOST=postgres
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=admin_pwd
    links:
      - db
  web:
    image: nginx
    ports:
      - 8080:80
    links:
      - nextcloud
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    volumes_from:
      - nextcloud

This example work for me.

Also show : https://github.com/nextcloud/docker/issues/345