Return to

How do I access MariaDB from other Docker containers?


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.



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:

$CONFIG = array (

  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => '',
  '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):


# * Basic Settings

port            = 3306
bind-address            =

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.