Docker - MariaDB Container Setup


Here I describe my setup of the Docker MariaDB container. MariaDB is a fork of the MySQL database. I use this database, among other things, to store data from Home Assistant. Furthermore, it is very easy to connect MariaDB to Grafana to visualize data.

I run this Docker container on a Ubuntu VM that runs via [[ Proxmox VE ]]. I perform the following on the CLI.

Docker pull command:

docker pull mariadb

Within my home folder I have created a Docker folder where I create a subfolder for each container:

cd ~
mkdir -p docker/mariadb
cd docker/mariadb

Also create folders where the MariaDB data and config files can be stored:

mkdir data
mkdir config

I use the Nano text editor to create a shell script:

sudo nano mariadb_run.sh

With this shell script we are going to create the container. Copy the following into mariadb_run.sh:

docker run -d \
 --hostname=mariadb \
 --name=mariadb \
 --net=host \
 -v $PWD/config:/etc/mysql/conf.d \
 -v $PWD/data:/var/lib/mysql \
 -e MYSQL_ROOT_PASSWORD=PASSWD \
 -e TZ="Europe/Amsterdam" \
 --restart=unless-stopped \
 mariadb

If necessary, adjust the following:

$PWD/config:/etc/mysql/conf.d
Choose the location for the MariaDB config. In this example it is the config map we created

$PWD/data:/var/lib/mysql
Choose the location for the MariaDB data. In this example it is the data map we created

MYSQL_ROOT_PASSWORD=PASSWD
Replace PASSWD with your own password

-e ‘TZ=Europe/Amsterdam’
Pick the right timezone

Exit Nano (CTRL-X) and save the changes.

Now create the container:

sudo sh mariadb_run.sh

Check if the container is running properly.

Using MariaDB

To handle the administration of MariaDB I personally use phpMyAdmin.

Here I describe how you can make daily backups of MariaDB databases

See also my notes about updating containers with Portainer or via the CLI. With Synology’s Docker Application, updating a container is also very easy.


Read other notes

Comments

    No comments found for this note.

    Join the discussion for this note on this ticket. Comments appear on this page instantly.

    Tags


    Notes mentioning this note

    • Docker - QuestDB Container Setup
      QuestDB is a high-performance, open-source SQL database. QuestDB’s stack is engineered from scratch, zero-GC Java and dependency-free. It includes endpoints...

    Notes Graph