Starting MariaDB with Docker
The official mariadb image provides a ready-to-use server. The command above runs a detached container, publishes port 3306, and stores data in the named volume mariadbdata. MARIADB_ROOT_PASSWORD is mandatory on first startup.
Data persistence
The internal data directory is /var/lib/mysql. Without a volume, data disappears when the container is removed. The named volume mariadbdata keeps your databases across recreations.
Customization and connection
Set MARIADB_DATABASE, MARIADB_USER, and MARIADB_PASSWORD to create a database and user at startup. Open a SQL shell with docker exec -it mariadb mariadb -u root -p; from the host, connect to localhost:3306 with any MySQL-compatible client.