Table 'nextcloud.oc_appconfig' doesn't exist | Internal Server Error

I have nextcloud 19 setup with docker compose.
The Host: Raspberry 4
My docker-compose.yml:

version: '3'

services:
  db:
    image: linuxserver/mariadb
#    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - /home/raspi/nextcloud-docker/volumen/mariadb/:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=sdfgsfghdfh
    env_file:
      - db.env

  app:
    image: nextcloud:apache
    restart: always
    volumes:
      - /home/raspi/nextcloud-docker/volumen/nextcloud/:/var/www/html
    environment:
      - VIRTUAL_HOST=site.com
      - LETSENCRYPT_HOST=site.com
      - LETSENCRYPT_EMAIL=site.com
      - MYSQL_HOST=db
    env_file:
      - db.env
    depends_on:
      - db
    networks:
      - proxy-tier
      - default

  haproxy:
    restart: always
    image: haproxy:2.1.7
    volumes:
      - /home/raspi/nextcloud-docker/haproxy/config:/usr/local/etc/haproxy/
      - /home/raspi/nextcloud-docker/haproxy/certs/haproxy/:/usr/local/etc/ssl/
    ports:
      - 8080:8080
    networks:
      - proxy-tier
    depends_on:
      - app

volumes:
  db:
  nextcloud:
  certs:
  vhost.d:
  html:

networks:
  proxy-tier:

This worked great until now. I wanted to setup an external storage and installed the app in nextcloud. After that i created a folder inside the docker container inside /media where i wanted to mount the external device. After that i did:

docker-compose down
docker-compose up --build -d

Then i got only a 500 Error on the page:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

The logfile:

[{"__class__":"Doctrine\\DBAL\\Exception\\TableNotFoundException"},500]}],"File":"/var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php","Line":90,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_appconfig' doesn't exist","Code":"42S02","Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php","line":88,"function":"query","class":"PDO","type":"->","args":["SELECT * FROM `oc_appconfig`"]},{"file":"/var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":908,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDOConnection","type":"->","args":["SELECT * FROM `oc_appconfig`"]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT * FROM `oc_appconfig`",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT * FROM `oc_appconfig`",[],[]]},{"file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":331,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":109,"function":"loadConfigValues","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":287,"function":"getApps","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_App.php","line":883,"function":"getValues","class":"OC\\AppConfig","type":"->","args":[false,"installed_version"]},{"file":"/var/www/html/lib/private/TemplateLayout.php","line":164,"function":"getAppVersions","class":"OC_App","type":"::","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":185,"function":"__construct","class":"OC\\TemplateLayout","type":"->","args":["error",""]},{"file":"/var/www/html/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":334,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/var/www/html/index.php","line":63,"function":"printExceptionErrorPage","class":"OC_Template","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Exception\\TableNotFoundException"},500]}],"File":"/var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php","Line":88}},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0","version":"19.0.0.12"}
{"reqId":"zrp8cOa5N3Dn9VJzEnZY","level":3,"time":"2020-07-06T19:24:53+00:00","remoteAddr":"192.168.128.2","user":"--","app":"PHP","method":"GET","url":"/ocs/v2.php/apps/notifications/api/v2/notifications?format=json","message":"Doctrine\\DBAL\\Exception\\TableNotFoundException: An exception occurred while executing 'SELECT * FROM `oc_appconfig`':\n\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_appconfig' doesn't exist at /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php#42","userAgent":"Mozilla/5.0 (Linux) mirall/2.6.4git (Nextcloud)","version":"19.0.0.12"}
{"reqId":"vNq8lQwg8dMttmdpbiTd","level":3,"time":"2020-07-06T19:24:53+00:00","remoteAddr":"192.168.128.2","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/mark/","message":"Error: Class 'OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin' not found at /var/www/html/remote.php#61","userAgent":"Mozilla/5.0 (Linux) mirall/2.6.4git (Nextcloud)","version":"19.0.0.12"}

Something is wrong with “nextcloud.oc_appconfig”. There are lots of oc_appconfig errors.

Has someone an idea what could be the problem?

Full logfile: https://pastebin.com/XXASwPWE

I have setup a new docker-compose with same docker-compose file. If i do:

docker-compose down
docker-compose up -d

i have no problem. But if i do:

docker-compose down
docker-compose up --build -d

i get the same error as above. So you should not do “–build”.

But does someone know how to fix the error?

Update:
Sometimes the same error happnes only by restarting the containers or by doing “down” and “up”. So probably nothing to do with “–build”.

I fount the solution:
The db container linuxserver/mariadb needed the uid and gid number from the host user.

Hi can you post a description of what you did to solve the problem? thanks.

Can you please expand on that?

So i forgot to put the PUID and PGID environment variable inside the docker-compose.yml db service. Like this:

services:
  db:
    image: linuxserver/mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=
      - PUID=109
      - PGID=65534
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=
    volumes:
      - /home/nextcloud/config/:/config

I encountered the same error. After

docker-compose down
docker-compose up -d

But these solutions above do not work for me though…
I have to remove all the containers and prune all the volumes which means it’s a fresh install…
I lost all my data, this is not acceptable

I used PostgreSQL as the database, this is the only difference.

After some research, I found that you cant just use

docker-compose down

to stop the container, cause docker-compose down will stop the container as well as remove them. so just use

docker-compose stop

this command stops the container but keeps them.

so I guess there’s something to do with container and volume links, those container hash should not be changed.

hope someone could explain this…