Access denied to database when using owncloud as docker container


I just had to restart my server, had to restart owncloud and its database, and now I’m getting a 500 error when trying to connect to owncloud. The owncloud logs show the following error:

owncloud_1     | [Thu Jun 28 18:00:52.317889 2018] [:error] [pid 26] [client] PHP Fatal error:  Uncaught exception 'Doctrine\\DBAL\\DBALException' with message 'Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'oc_myusername'@'' (using password: YES)' in /var/www/html/lib/private/DB/Connection.php:58\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/lib/private/DB/Connection.php(141): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine in /var/www/html/lib/private/DB/Connection.php on line 58


I run owncloud in a docker container, using mariadb as its database. Here’s my docker-compose.yml:

version: '2'

    image: owncloud:9.1
    container_name: fullbackup_owncloud
      - owncloud_db
      - portnumber:portnumber
      - "~/fullbackup/data:/var/www/html/data"
      - "~/fullbackup/owncloud_config:/var/www/html/config"
    restart: always

    image: mariadb
    container_name: fullbackup_db
      MYSQL_ROOT_PASSWORD: apassword
    restart: always

In my host’s ~/fullbackup/owncloud_config I have the following config.php:

$CONFIG = array (
  'instanceid' => 'someid',
  'passwordsalt' => 'somesalt',
  'secret' => 'somesecret',
  'trusted_domains' => 
  array (
    0 => 'myip',
  'datadirectory' => '/var/www/html/data',
  'overwrite.cli.url' => 'myip:someport',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'fullbackup_database_name',
  'dbhost' => 'owncloud_db',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_myusername',
  'dbpassword' => 'anotherpassword',
  'logtimezone' => 'UTC',
  'installed' => true,
  'filelocking.enabled' => false,

I’ve been able to thus run owncloud smoothly for using just docker-compose up

What I’ve tried

I’ve tried to follow the advice here:

$ docker exec -ti fullbackup owncloud_db
$ mysql_upgrade --force -u root -p
Phase 1/6: Checking and upgrading mysql database
Processing databases
mysql.column_stats                                 OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.gtid_slave_pos                               OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK                                         OK
mysql.index_stats                                  OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.roles_mapping                                OK
mysql.servers                                      OK
mysql.table_stats                                  OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Phase 2/6: Fixing views
Phase 3/6: Running 'mysql_fix_privilege_tables'
Phase 4/6: Fixing table and database names
Phase 5/6: Checking and upgrading tables
Processing databases
Phase 6/6: Running 'FLUSH PRIVILEGES'

But I get the same error.

I’ve also seen the advice here:

But this won’t let me use the pre-existing db user.

Any thoughts on what I can do to fix this?