Nextcloud docker container tries to install upon restarts

I’m currently setting up a new nextcloud instance, following the instructions on the image at docker hub.

So I came out with the following docker-compose (for completeness: jwilder/nginx-proxy and letsencrypt companion are started by another script, just not visible here).

version: '3'
services:
  freundx-nc-postgres:
	image: postgres:13.0-alpine
	container_name: freundx-nc-postgres
	volumes:
		- /mnt/E/dockervolumes/freundx-nc/postgres/var/lib/postgresql/data:/var/lib/postgresql/data
		- /etc/localtime:/etc/localtime:ro
		- /etc/timezone:/etc/timezone:ro
	environment:
		- POSTGRES_PASSWORD=<censored>
		- POSTGRES_USER=nextcloud
		- POSTGRES_DB=nextcloud
	logging:
		driver: "json-file"
		options:
			max-size: "50m"
			max-file: "2"
	networks:
		- freundx

  freundx-nc-nextcloud:
	image: nextcloud:19.0.3-apache
	container_name: freundx-nc-nextcloud
	volumes:
		- /etc/localtime:/etc/localtime:ro
		- /etc/timezone:/etc/timezone:ro
		- /mnt/E/dockervolumes/freundx-nc/nextcloud/var/www/html/custom_apps:/var/www/html/custom_apps
		- /mnt/E/dockervolumes/freundx-nc/nextcloud/var/www/html/data:/var/www/html/data
	environment:
		- "POSTGRES_HOST=freundx-nc-postgres"
		- "POSTGRES_DB=nextcloud"
		- "POSTGRES_USER=nextcloud"
		- "POSTGRES_PASSWORD=censored"
		- "NEXTCLOUD_ADMIN_USER=admin"
		- "NEXTCLOUD_ADMIN_PASSWORD=censored"
		- "NEXTCLOUD_TRUSTED_DOMAINS=my.domain.de"
		- "APACHE_DISABLE_REWRITE_IP=1"
		- "VIRTUAL_HOST=my.domain.de"
		- "LETSENCRYPT_HOST=my.domain.de"
		- "VIRTUAL_PORT=80"
	logging:
		driver: "json-file"
		options:
			max-size: "50m"
			max-file: "2"
	networks:
		- freundx


networks:
  freundx:
	external: true

First start with empty volumes works perfectly, I can access nextcloud at the configured url and upload/download files.

But when I stop and start the containers (docker-compose rm -sf && docker-compose up -d), it obviously tries to install itself to the db, although the db is already set up:

	/opt/freundx/dockerscripts/freundx-nextcloud-new$ docker logs -f freundx-nc-nextcloud
Conf remoteip disabled.
To activate the new configuration, you need to run:
  service apache2 reload
Initializing nextcloud 19.0.3.1 ...
Initializing finished
New nextcloud instance
Installing with PostgreSQL database
starting nextcloud installation
Error while trying to initialise the database: An exception occurred while executing 'CREATE TABLE oc_migrations (app VARCHAR(255) NOT NULL, version VARCHAR(255) NOT NULL, PRIMARY KEY(app, version))':

SQLSTATE[42P07]: Duplicate table: 7 ERROR:  relation "oc_migrations" already exists
 ->
retrying install...
Error while trying to initialise the database: An exception occurred while executing 'CREATE TABLE oc_migrations (app VARCHAR(255) NOT NULL, version VARCHAR(255) NOT NULL, PRIMARY KEY(app, version))':

SQLSTATE[42P07]: Duplicate table: 7 ERROR:  relation "oc_migrations" already exists

Any idea how I can avoid this? Maybe there is some environment variable I missed or s.th. like that?

nextcloud is installed into /var/www/html. and the config (database credentials) are stored in /var/www/html/config.

in your case this is inside the container. and delete by docker-compose rm -sf

ok?