After Docker restart: Nextcloud want to install again

Hi,

I’m using the official Docker image (fpm-alpine, nginx, postgres, redis) and docker-compose to configure Nextcloud. I set the environment variables NEXTCLOUD_ADMIN_USER, NEXTCLOUD_ADMIN_PASSWORD.

I set the volumes

  • nextcloud:/var/www/html
  • ./data/nextcloud-data:/var/www/html/data

After I run docker-compose up the config.php was automatically created with correct entries (even trusted_proxies and trusted_domains) and I think I could login with admin user, defined by the environment variables. (to be honest, I’m not 100% sure)

Afterwards set up the normal users, synced my phone, installed nc-apps, everything was fine. Then I played around (e.g. put SMTP/MAIL variables in the env_file) and prune the nextcloud-volume (but not the data-volume and db-volume [./data/nextcloud-db:/var/lib/postgresql/data]) and restarted. Now it ask to add a admin account again and to finish the installation. My data is still there and the before created users in the postgres-db, too. But why doesn’t it use the existing installation? What do I miss?

In the postgres database i found 26 db-users (admin… admin25). It seems with each new attempt nextcloud created a new db user, even though I passed the db credentials via a env_file.

Is it because the auto-generated config.php has a different value in instanceid?

I thought it is the idea of docker-images was to throw away the container and restart with no hassle. :slight_smile:

Best

Keywan

the existing installation was in that volume. you deleted it.

in the nc image you only have the “source code” somewhere in /usr/src/nextcloud. this is done in the dockerfile below here: https://github.com/nextcloud/docker/blob/master/22/apache/Dockerfile#L134. above that line php&apache is installed and configured in the image. not nextcloud itself.

on image start, when the container is created, the following lines check if nextcloud is installed into the volume you delete. here: https://github.com/nextcloud/docker/blob/master/22/apache/entrypoint.sh#L81

in your case if [ -f /var/www/html/version.php ]; then fails because files isn’t there anymore. that triggers the installation of nextcloud. and that the way you’ll get an update. next time. :wink:

unless you touch the volumes with the persistent data.

management summary: your installation is broken. delete everything and start over.

1 Like

Hi,

thanks for your answer. At least my installation wasn’t productive yet. I will restart, as you recommended.

But as far as I understand the nextcloud image is not built consistent with the docker philosophy, or? Shouldn’t the code be different from the persistent data? What is the advantage of nextcloud in docker to a normal installation? I just try to understand.

And why does it ignores the admin-user variables in the env_file?

After I created the user, can I move their former files in their data directory, to save some time?

Dankeschön

Keywan

kind of. but no.

there are too many files in /var/www/nextcloud that are volatile or user generated. all these sub folders listed in this file: https://github.com/nextcloud/docker/blob/master/22/apache/upgrade.exclude

that’s one of the reasons why nextcloud isn’t “installed” during the build of the image. also during installation an admin user has to be created. how to do this during the build phase? there is no database running at that moment.

i run two instances along with watchtower. and they are always up2date. so i don’t care about updates. that’s pretty neat. and i don’t have to care about the underlying os. and the hustleand bustle with php updates.

and:

if you didn’t clean up your database i guess the problem is the undefined state you run into. that is to say existing db with new config.php.

sure. but only the files folder in nextcloud data. not the “meta datas”. e.g. trashbin folder.
and run a docker exec -u www-data nextcloud php occ files:rescan --all to update your database.

1 Like

Hallo Reiner,

thanks again for your patience and explanations. They were very helpful.

Best regards und schönes Wochenende

Keywan