MariaDB is a database management system that is a fork of MySQL, primarily maintained by the open-source community and licensed under GPL. The goal of MariaDB is to be fully compatible with MySQL, including the API and command line, making it an easy replacement for MySQL.
1. Search for the MariaDB image (ensure Docker and Docker Compose are installed)
docker search mariadb
2. Download the image (generally download the one with the most STARS)
docker pull mariadb
3. View the images
docker images
4. Create a directory for mapping with the container
mkdir /home/pi/mariadb/{log,conf,data} -p
5. Start the MariaDB instance
Set MYSQL_ROOT_PASSWORD, the password for the root user of the database to “raspberry”.
docker run -id --name mariadb_test
-v /home/pi/mariadb/conf:/etc/mysql/conf.d
-v /home/pi/mariadb/logs:/var/log/mysql
-v /home/pi/mariadb/data:/var/lib/mysql
-e TZ=Asia/Shanghai
-e MYSQL_ROOT_PASSWORD=raspberry
-p 3306:3306 mariadb
6. View the running containers
docker ps -a
7. Access the container and log in to the database
docker exec -it mariadb_test /bin/bash
root@060476e080a8:/# mariadb -u root -pEnter password: