Return to Level1Techs.com

How do I access MariaDB from other Docker containers?

#1

Trying to set up MariaDB for Nextcloud and Wordpress (in future for even more). Right now I want to have each of them in their own container (“isql” for db, “next” and “wp”). I didn’t find a solution startpaging, but I understood it’s probably something to do with networks, but I was unsuccessful getting anything running correctly.
If next’s and wp’s config is similar, I’d need only one. Could someone please guide me how would I need to run MariaDB and say only NextCloud from seperate instances? Note: also using Traefik.

0 Likes

#2

In your Nextcloud config.php you just point it to the network address of your MariaDB instance, specify the db name, user and password, if you leave port blank, it assumes the default port of 3306. My config for example:

<?php
$CONFIG = array (
  
...

  'dbtype' => 'mysql',
  'version' => '15.0.7.0',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb-server.danger-rocket.com',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'ncuser',
  'dbpassword' => '***your password***',

...

);

I think the default MariaDB install binds to all interfaces, but you can make sure in your mariadb config. Mine for example (/etc/mysql/mariadb.conf.d):

[mysqld]

#
# * Basic Settings
#

port            = 3306
bind-address            = 0.0.0.0

And in mariadb itself, you just have to make sure that the user you supplied to the nextcloud config has all the appropriate permissions to modify the db.

0 Likes