docker mariadb or mysql

AnosVoldigoad

Dabbler
Joined
Apr 4, 2021
Messages
17
Hi together,

I have been trying to set up one of these two docker for the last few days:

The problem I ran into is that I don't know what GID/UID I need to set up on the mounted folders?

Another way I might have found, but don't know if that's right, is to customize the config as well. But that does not work in Truena's Scale on the GUI:
e.g.: docker container run --user 1000:1000

Can someone help me how to do this best? I am still quite inexperienced with docker.

Translated with www.DeepL.com/Translator (free version)
 

youre_mom

Cadet
Joined
Jun 14, 2022
Messages
1
Did you already figure out how to run mariadb (or mysql) as a docker on TrueNas scale?
 

ohmcodes

Cadet
Joined
Dec 23, 2022
Messages
1
Im trying to host mysql to my truenas scale pod application, made a user and database then when i suddenly restart it to apply changes it deletes everything so i was thinking should i use docker compose instead not this pod app? or maybe im missing something...
 

truzzles

Cadet
Joined
Jan 19, 2024
Messages
2
Hello!

I too am trying to set up a mysql Custom Application without success, my problem is I cant reach mysql from outside the pod. I believe I managed to start the container and make it use my dataset, if I open a shell I can log in to mysql and create users and issue queries, the logs all look fine but from my desktop machine I cannot reach that mysql container.

Here are the steps I have taken:
(I assume you have a dataset ready to use, mine is at /mnt/pool-01/mysql)
  1. Log in and go to Applications -> Discover -> Custom App
  2. Application Name: mysql
  3. Image repository: mysql
  4. Environmental Variables:
    1. MYSQL_ROOT_PASSWORD = changeme
    2. MYSQL_TCP_PORT= 9306
  5. Storage -> Host Path Volumes
    1. Point Host Path to your TrueNAS Pool, mine is /mnt/pool-01/mysql
    2. Mount Path: /var/lib/mysql
  6. Port forward (probably what Im doing wrong):
    1. Container Port: 3306
    2. Node Port: 9306
  7. Add the rule to iptables
    1. nano /etc/network/iptables-script.sh
    2. Code:
      #!/bin/bash
      iptables -A INPUT -p tcp --dport 9306 -j ACCEPT
    3. chmod +x /etc/network/iptables-script.sh
    4. sudo nano /etc/systemd/system/iptables.service
    5. Code:
      [Unit]
      Description=Custom iptables rule
      [Service]
              Type=oneshot
              ExecStart=/etc/network/iptables-script.sh
              [Install]
              WantedBy=multi-user.target
      
  8. Networking
    1. Host Interface: Choose your network interface, mine is enp6s0
    2. IPAM: use DHCP

This makes a Custom Application that starts mysql, but like I said above, I cannot reach that database.
I did check and the my.cnf file does not have a bind-address rule, and checking the logs I see:

/usr/sbin/mysqld: ready for connections. Version: '8.3.0' socket: '/var/run/mysqld/mysqld.sock' port: 9306

The reason why Im using port 9306 is because I could not get port forwarding to work with port 3306, and at first I tried without any port forwarding at all but that also did not work.
 

truzzles

Cadet
Joined
Jan 19, 2024
Messages
2
well I have made some progress and I believe the problem is related to the container's firewall, I didnt spend much time on it but the Dockerfile is an oraclelinux which I believe is based off fedora, but the workaround I found was to add the Dependency train to the Truecharts catalog, that enables MariaDB to be installed and for me it worked without any tricks, just set a few credentials when installing and thats it!
 
Top