MariaDB access for Docker containers

Currently reading
MariaDB access for Docker containers

10
1
NAS
Synology DS218+
Operating system
  1. Windows
Mobile operating system
  1. Android
Hi,
I'm having general issues connecting my docker containers to MariaDB 10 (installed through Synology packages center, version 10.3.21-0063).

For example, with the great tutorial from wwwampy, when I put the variables for database (LAN IP from NAS with port 3307), it fails to connect. I also tried with "localhost" / "127.0.01". I've already created the database and user with phpMyAdmin.

On the otherside, I was able to connect Nextcloud (webstation version) with LAN IP address and port to MariaDB 10.

I feel like I'm missing something. Would someone be nice enough to help a newbie ? :D

Thanks in advance et stay healthy
 

Rusty

Moderator
NAS Support
2,353
701
www.blackvoid.club
NAS
DS412+, DS718+, DS918+, 2x RS3614RPxs+ with expansions
Router
  1. RT1900ac
  2. RT2600ac
  3. MR2200ac
Operating system
  1. macOS
Mobile operating system
  1. iOS
LAN IP address and port to MariaDB 10
What port are you running Maria on? In some cases, Maria/mysql is running on 3306 and in some on 3307 port. So what port are you using with Nextcloud for example?
 
10
1
NAS
Synology DS218+
Operating system
  1. Windows
Mobile operating system
  1. Android
Thank you for your answer.

For Nextcloud, I use port 3307
'dbname' => 'nextcloud2',
'dbhost' => '192.168.1.156:3307',
 

Rusty

Moderator
NAS Support
2,353
701
www.blackvoid.club
NAS
DS412+, DS718+, DS918+, 2x RS3614RPxs+ with expansions
Router
  1. RT1900ac
  2. RT2600ac
  3. MR2200ac
Operating system
  1. macOS
Mobile operating system
  1. iOS
Then I guess DB is broadcasting on port 3307 on your nas and docker containers should pick it up without any problem.

What container are you trying to run? Firefly?

If so, then make sure that the DB_HOST variable is configured not just with the ip address of the DB host (in your case that's your NAS IP) but also the port. So just like with dbhost parameter for nextcloud, use IP_ADDRESS: PORT as a value.

Also, Firefly can use 2 more variables if setting up a specific port as a variable is needed.

DB_CONNECTIONmysql
DB_PORTport number
 
10
1
NAS
Synology DS218+
Operating system
  1. Windows
Mobile operating system
  1. Android
I tried with IP:pORT with no success. I thought this was an easy fix but it doesn't seem so. So I resorted in creating a new MariaDB database with docker and connected through docker bridge. And now it works. My only fear is that i've seen that docker bridge IPs change when I restart the NAS.
Thank you for your help ! :)
 

Rusty

Moderator
NAS Support
2,353
701
www.blackvoid.club
NAS
DS412+, DS718+, DS918+, 2x RS3614RPxs+ with expansions
Router
  1. RT1900ac
  2. RT2600ac
  3. MR2200ac
Operating system
  1. macOS
Mobile operating system
  1. iOS
My only fear is that i've seen that docker bridge IPs change when I restart the NAS.
It won't don't worry. Still bare metal Maria should work. Glad you got it sorted via docker alternative.
 
2
0
NAS
DS218+
Operating system
  1. macOS
Mobile operating system
  1. iOS
Had the same issue, I resolved it by choosing "Host" for network instead of "Bridge". if you already have the container created, you have to delete and recreate again.
 
By default the MariaDB package only allows root access from localhost/127.0.0.1. This is why it works with mode=host and did not with mode=bridge. In mode=host the container shares the namepsace for the network device with the host (read: behaves network-wise exactl like the host). Btw: you can set and/or see the port in DSM's MariaDB configuration ui.

If you want to connect a container in the bridged network, you might want to read this link: Question - MariaDB 10 Error: 2006 MySQL server has gone away
 
2
0
NAS
DS218+
Operating system
  1. macOS
Mobile operating system
  1. iOS
By default the MariaDB package only allows root access from localhost/127.0.0.1. This is why it works with mode=host and did not with mode=bridge. In mode=host the container shares the namepsace for the network device with the host (read: behaves network-wise exactl like the host). Btw: you can set and/or see the port in DSM's MariaDB configuration ui.

If you want to connect a container in the bridged network, you might want to read this link: Question - MariaDB 10 Error: 2006 MySQL server has gone away
Ah that makes sense. Thanks mate!
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Similar threads

Similar threads

Top