docker icon indicating copy to clipboard operation
docker copied to clipboard

Wrong installation when using NEXTCLOUD_ADMIN_USER

Open gwisp2 opened this issue 5 years ago • 8 comments

Automatic installation with set NEXTCLOUD_ADMIN_USER is not working properly. Failure example: repository.

NEXTCLOUD_ADMIN_USER=gwisp POSTGRES_USER=nextcloud_user

In logs it can be seen that database tables are created by nextcloud_user and when handling requests they are accessed by oc_gwisp user causing permission errors. In normal installation (when credentials are entered via browser) everything is ok because tables are created with oc_gwisp user.

db_1         | 2020-08-19 22:13:35.270 GMT [58] [oc_gwisp, nextcloud_db]ERROR:  permission denied for table oc_appconfig
db_1         | 2020-08-19 22:13:35.270 GMT [58] [oc_gwisp, nextcloud_db]STATEMENT:  SELECT * FROM "oc_appconfig"

gwisp2 avatar Aug 19 '20 22:08 gwisp2

Update: Happened to me when switching from postgres:11 to postgres:latest

I think it is a file permission issue. I used a local host volume for the - ./database:/var/lib/postgresql/data, and switched to a docker volume instead. After using the docker volume and docker-compose down -v and spinning it up again it worked (even with the latest postgres)

JustinGuese avatar Dec 01 '20 11:12 JustinGuese

I'm seeing the same thing, but in our case, a docker-compose down -v didn't resolve the issue.

We investigated and found that the user written to config.php is actually not the one defined by the POSTGRES_USER environment variable, but instead oc_nextcloud.

This is in image d02b2bb3e283 while c664af0d9c67 still seems to be working fine.

kwisatz avatar Mar 08 '21 14:03 kwisatz

I'm seeing this and I'm wondering whether nextcloud isn't attempting to install the DB too early, fails and then decides to use a default username/password combination instead.

Initializing nextcloud 20.0.8.1 ...
Initializing finished
New nextcloud instance
Installing with PostgreSQL database
starting nextcloud installation
PostgreSQL username and/or password not valid
 -> You need to enter details of an existing account.
retrying install...
Nextcloud was successfully installed

kwisatz avatar Mar 08 '21 14:03 kwisatz

Hey, yes it is definitely a problem with PostgreSQL, it worked way better when I used a MariaDB image. I found some other threads complaining about PostgreSQL performance with Nextcloud, even though I can't link it rn.

On Mar 8 2021, at 3:25 pm, David Raison [email protected] wrote:

I'm seeing this and I'm wondering whether nextcloud isn't attempting to install the DB too early, fails and then decides to use a default username/password combination instead. Initializing nextcloud 20.0.8.1 ... Initializing finished New nextcloud instance Installing with PostgreSQL database starting nextcloud installation PostgreSQL username and/or password not valid -> You need to enter details of an existing account. retrying install... Nextcloud was successfully installed — You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://link.getmailspring.com/link/[email protected]/0?redirect=https%3A%2F%2Fgithub.com%2Fnextcloud%2Fdocker%2Fissues%2F1204%23issuecomment-792789821&recipient=cmVwbHkrQUNKRkEyNTRYS0pBQUM2M0xKNVJSNE42S0lLTzVFVkJOSEhDUktQS0JFQHJlcGx5LmdpdGh1Yi5jb20%3D), or unsubscribe (https://link.getmailspring.com/link/[email protected]/1?redirect=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACJFA23CF7ADZIFN5MLK6TDTCTM65ANCNFSM4QFNNJXQ&recipient=cmVwbHkrQUNKRkEyNTRYS0pBQUM2M0xKNVJSNE42S0lLTzVFVkJOSEhDUktQS0JFQHJlcGx5LmdpdGh1Yi5jb20%3D).

JustinGuese avatar Mar 08 '21 14:03 JustinGuese

I'm wondering whether nextcloud isn't attempting to install the DB too early

I can confirm that for me, bringing only the DB up (docker-compose up <db-service-name>) waiting (look at docker logs <db-container>) and then the app fixed the issue for me.

gzm0 avatar Mar 11 '21 17:03 gzm0

Using Kubernetes I'm seeing the same issue. I have added an init-container that prevents Nextloucd from starting until pg_wait responds that the database is connectable but it is still happening.

zimmertr avatar Apr 03 '21 18:04 zimmertr

Any updates on this? The latest mariadb image is also broken with Nextcloud, so this is kind of the only option if you don't want to keep MariaDB pinned at an old version.

poperigby avatar Jan 13 '22 00:01 poperigby

I also struggled with this.. solution was to let DB to initialize first and then run all other containers:

$ docker compose up --no-start -d
$ docker compose start db
$ docker compose logs db
.... wait ....
$ docker compose start

goranskular avatar May 14 '22 07:05 goranskular