Owncloud server doesn't seem to populate database with tables

I was hoping that someone had a sql script that would initialize the database.

Steps to reproduce

  1. I created a docker compose with a remote mariadb server as the target for mysql here:

version: ‘2.1’

    driver: local
#  mysql:
#    driver: local
    driver: local
    driver: local

    image: owncloud/server:${OWNCLOUD_VERSION}
    restart: always
      - ${HTTP_PORT}:8080
#      - db
      - redis
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
      - files:/mnt/data

#  db:
#    image: webhippie/mariadb:latest
#    restart: always
#    environment:
#      - MARIADB_ROOT_PASSWORD=owncloud
#      - MARIADB_USERNAME=owncloud
#      - MARIADB_PASSWORD=owncloud
#      - MARIADB_DATABASE=owncloud
#    healthcheck:
#      test: ["CMD", "/usr/bin/healthcheck"]
#      interval: 30s
#      timeout: 10s
#      retries: 5
#    volumes:
#      - mysql:/var/lib/mysql
#      - backup:/var/lib/backup

    image: webhippie/redis:latest
    restart: always
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
      - redis:/var/lib/redis
  1. I setup a mariadb that I can access remotely. In fact the error message suggests that it is accessing the DB and failing to find the first table. You can see the output here:

owncloud_1 | Waiting for MySQL…
owncloud_1 | services are ready!
owncloud_1 | Waiting for Redis…
owncloud_1 | services are ready!
owncloud_1 | Writing config file…
owncloud_1 | Fixing base perms…
owncloud_1 | Fixing data perms…
owncloud_1 | Fixing hook perms…
owncloud_1 | Upgrading server database…
owncloud_1 | An unhandled exception has been thrown:
owncloud_1 | PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘owncloud.oc_appconfig’ doesn’t exist in /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:88
owncloud_1 | Stack trace:
owncloud_1 | #0 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(88): PDO->query(‘SELECT * FROM ...') owncloud_1 | #1 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(910): Doctrine\DBAL\Driver\PDOConnection->query('SELECT * FROM …’)
owncloud_1 | #2 /var/www/owncloud/lib/private/DB/Connection.php(187): Doctrine\DBAL\Connection->executeQuery(‘SELECT * FROM ...', Array, Array, NULL) owncloud_1 | #3 /var/www/owncloud/lib/composer/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(200): OC\DB\Connection->executeQuery('SELECT * FROM …’, Array, Array)
owncloud_1 | #4 /var/www/owncloud/lib/private/DB/QueryBuilder/QueryBuilder.php(141): Doctrine\DBAL\Query\QueryBuilder->execute()
owncloud_1 | #5 /var/www/owncloud/lib/private/AppConfig.php(301): OC\DB\QueryBuilder\QueryBuilder->execute()
owncloud_1 | #6 /var/www/owncloud/lib/private/AppConfig.php(80): OC\AppConfig->loadConfigValues()
owncloud_1 | #7 /var/www/owncloud/lib/private/AppConfig.php(278): OC\AppConfig->getApps()
owncloud_1 | #8 /var/www/owncloud/lib/private/legacy/app.php(948): OC\AppConfig->getValues(false, ‘installed_versi…’)
owncloud_1 | #9 /var/www/owncloud/lib/private/Server.php(438): OC_App::getAppVersions()
owncloud_1 | #10 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
owncloud_1 | #11 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet(‘MemCacheFactory’)
owncloud_1 | #12 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query(‘MemCacheFactory’)
owncloud_1 | #13 /var/www/owncloud/lib/private/Server.php(1202): OC\ServerContainer->query(‘MemCacheFactory’)
owncloud_1 | #14 /var/www/owncloud/lib/private/Server.php(597): OC\Server->getMemCacheFactory()
owncloud_1 | #15 /var/www/owncloud/lib/composer/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))
owncloud_1 | #16 /var/www/owncloud/lib/private/AppFramework/Utility/SimpleContainer.php(108): Pimple\Container->offsetGet(‘AppManager’)
owncloud_1 | #17 /var/www/owncloud/lib/private/ServerContainer.php(86): OC\AppFramework\Utility\SimpleContainer->query(‘AppManager’)
owncloud_1 | #18 /var/www/owncloud/lib/private/Server.php(1418): OC\ServerContainer->query(‘AppManager’)
owncloud_1 | #19 /var/www/owncloud/lib/private/legacy/app.php(343): OC\Server->getAppManager()
owncloud_1 | #20 /var/www/owncloud/lib/private/legacy/app.php(107): OC_App::getEnabledApps()
owncloud_1 | #21 /var/www/owncloud/lib/base.php(585): OC_App::loadApps(Array)
owncloud_1 | #22 /var/www/owncloud/lib/base.php(1058): OC::init()
owncloud_1 | #23 /var/www/owncloud/console.php(74): require_once(’/var/www/ownclo…’)
owncloud_1 | #24 /var/www/owncloud/occ(11): require_once(’/var/www/ownclo…’)
owncloud_1 | #25 {main}

Expected behaviour

I expect that given that I have given access to the DB with no owncloud database that owncloud would recognize and install itself on the DB.

Actual behaviour

Instead it seemed to check for tables and database then error out when they were not present.

Server configuration

Operating system: PopOS 19.04 (Debian / Ubuntu)

Web server: I left the images for Owncloud and Redis the same as the latest.

Database: Mariadb 5.5.29-standard

PHP version: Owncloud latest

ownCloud version: (see ownCloud admin page) Latest

Updated from an older ownCloud or fresh install: Fresh Install

Where did you install ownCloud from: From Docker Hub

Signing status (ownCloud 9.0 and above): Not sure

Login as admin user into your ownCloud and access 
paste the results into https://gist.github.com/ and puth the link here.

The content of config/config.php:
Latest standard config

Log in to the web-UI with an administrator account and click on
'admin' -> 'Generate Config Report' -> 'Download ownCloud config report'
This report includes the config.php settings, the list of activated apps
and other details in a well sanitized form.


If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your ownCloud installation folder

*ATTENTION:* Do not post your config.php file in public as is. Please use one of the above
methods whenever possible. Both, the generated reports from the web-ui and from occ config:list
consistently remove sensitive data. You still may want to review the report before sending.
If done manually then it is critical for your own privacy to dilligently
remove *all* host names, passwords, usernames, salts and other credentials before posting.
You should assume that attackers find such information and will use them against your systems.

List of activated apps:
No apps yet

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your ownCloud installation folder.

Are you using external storage, if yes which one: local/smb/sftp/…
Trying just a straight connection to Mariadb
Are you using encryption: yes/no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/…

Did you execute the docker-compose before? Does the “files” volume contain information from the previous run?

It seems the startup script is assuming you want to upgrade because there might be some information in the “files” volume. I’d recommend to remove all the volumes and start over again.