Public | Automated Build

Last pushed: 2 years ago
Short Description
Centos 7 MariaDB 10.1 with TokuDB support
Full Description

MariaDB 10.1 Docker Image (Centos7)

This is a MariaDB 10.1 Docker sjmcdowall/centos_mariadb_tokudb image. Built on top of an official centos:7 image. Inspired heavily by Million12's dokcer-mariadb which in turn was inspired by Tutum's tutum/mariadb image.

The main change here is updating to use MariaDB 10.1 (latest) and giving an easy way to modify the version to whatever you want as well as making TokuDB active and the primary storage engine.

Note: be aware that, by default in this container, MariaDB is configured to use 1GB memory (innodb_buffer_pool_size in tuning.cnf). If you try to run it on node with less memory, it will fail.


Docker and Docker-Compose are required to run this application, which are packaged together for Mac and Windows users into Docker Toolbox, for Linux users, follow the instructions for installing theDocker Engine and Docker Compose.

Building the MariaDB service

After installing the Docker dependencies, run the following from the command line at the root of this directory :

make docker

That command will build an image (using the Dockerfile "recipe" in this project folder) from which containers can be created.

Running the Container

This container depends on a bit of hierarchy where the MariaDB db data dir resides. Specifically, it assumes there will be a tokudb folder under the main dbdata folder specificed in the appropriate -v (or volumes) area. This needs to be present before running the container for the first time otherwise it will not initalize the various db files correctly.

A simple command like :

mkdir -p dbdir/tokuDB

before running is all that is needed.

Running via docker run

This container can be run from the command line like this:

docker run --name=mariadb -d -v ./dbdata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=<password> sjmcdowall/centos_mariadb_tokudb

Those commands build a data container (to persist the data in a docker volume) as well as the mariadb containerized service. It is linked to the data container (which was exposed as a docker volume). The service also has a root password passed in as an environment variable (see below for additional variables that can be set).

The mysqld service has many additional command-line options to fine-tune the service and due to the way this docker image is configured, you can pass any of those options to this container as if you were passing them to the mysqld CLI directly. Just pass a command to override the default "optionless" mysqld_safe command, placing them at the end of the docker run command listed above, for example:

docker run --name=mariadb -d --build-arg MARIA_VERSION=10.1 -v ./dbdata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=<password> centos_mariadb_tokudb mysqld_safe --log-error=/var/log/mysql.err --pid-file=/var/run/

Even easier is to run this via docker-compse. There is a sample docker-compose.yml file included in this git repo that can be used as a starting point. Once modified than a simple:

docker-compose up -d

Should get everything running.

Accessing MariaDB from outside the container

Standard MySQL/MariaDB port # 3306 has been exposed to the outside world @ port 3306. So to connect to the running DB should be as easy as :

mysql -h -u root -pxxxxx

Where xxxxx is of course the default root password specified at run time on the first launch via the appropriate ENV variable.

Environment variables

  • MYSQL_ROOT_PASSWORD - The (required) root user password.
  • MYSQL_USER - A non-root user to set up (must also include a password).
  • MYSQL_PASSWORD - A password for the non-root user being set up.
  • MARIA_VERSION - When building the image, you can set a version corresponding with those found at (defaults to 10.1)
Docker Pull Command