Dockerfile to build a MariaDB Server Image.
- Configuration tweaked to use all around settings for general usage - Can be changed
- Can use official Mysql/MariaDB environment variables (MYSQL_USER, MYSQL_PASSWORD, MYSQL_ROOT_PASSWORD)
- Allows for automatically creating multiple databases on container initialization
- Automatic Table/DB Upgrade support if MariaDB version has changed
- Includes MySQL Tuner inside image to optimize your configuration
- Zabbix Monitoring for metrics
Also has the capability of backing up embedded in the container based on the rusxakep/dbbackup image which includes the following features:
-
dump to local filesystem
-
Backup all databases
-
choose to have an MD5 sum after backup for verification
-
delete old backups after specific amount of time
-
choose compression type (none, gz, bz, xz)
-
select how often to run a dump
-
select when to start the first dump, whether time of day or relative to container start time
-
This Container uses a customized Alpine Linux base which includes s6 overlay enabled for PID 1 Init capabilities, zabbix-agent for individual container monitoring, Cron also installed along with other tools (bash,curl, less, logrotate, mariadb-client, nano, vim) for easier management. It also supports sending to external SMTP servers..
- Introduction
- Authors
- Table of Contents
- Prerequisites
- Installation
- Configuration
- Maintenance
- References
Automated builds of the image are available on Docker Hub and is the recommended method of installation.
docker pull rusxakep/mariadb
-
The quickest way to get started is using docker-compose. See the examples folder for a working docker-compose.yml that can be modified for development or production use.
-
Set various environment variables to understand the capabilities of this image.
-
Map persistent storage for access to configuration and data files for backup.
The following directories are used for configuration and can be mapped for persistent storage.
Directory | Description |
---|---|
/var/lib/mysql |
MySQL Data Directory |
/etc/mysql/conf.d |
Optional directory to put .cnf files for additional directives |
/backup |
Optional directory for backups |
Along with the Environment Variables from the Base image, below is the complete list of available options that can be used to customize your installation.
Parameter | Description | Default |
---|---|---|
CHARACTER_SET |
Set Default Character Set | utf8mb4 |
COLLATION |
Set Default Collation | utf8mb4_general_ci |
ROOT_PASS |
Root Password for Instance (e.g. password) | |
DB_AUTO_UPGRADE |
If MariaDB has changed from first time image has been used, automatically upgrade DBs and tables to latest versions - TRUE / FALSE |
TRUE |
DB_CONFIGURATION |
Type of Configuration - standard , or default |
standard |
DB_NAME |
Optional - Automatically Create Database - Seperate with commas for multiple databases | |
DB_USER |
Optional - Automatically Assign Username Priveleges to Database (e.g. mysqluser ) |
|
DB_PASS |
Password for authentication to above database (e.g. password ) |
- With regards to
DB_CONFIGURATION
default
- Means the default my.cnf file from MariaDBstandard
- My own settings that I find work for my own DB servers.
This image can also backup databases on a scheduled basis as well. These environment variables are:
Parameter | Description | Default |
---|---|---|
DB_BACKUP |
Enable TRUE or disable FALSE embedded backup routines |
FALSE |
DB_BACKUP_COMPRESSION |
Use either Gzip GZ , Bzip2 BZ , XZip XZ , or none NONE |
GZ |
DB_BACKUP_DUMP_FREQ |
How often to do a dump, in minutes. Defaults to 1440 minutes, or once per day. | |
DB_BACKUP_DUMP_BEGIN |
What time to do the first dump. Defaults to immediate. Must be in one of two formats | |
Absolute HHMM, e.g. 2330 or 0415 |
||
Relative +MM, i.e. how many minutes after starting the container, e.g. +0 (immediate), +10 (in 10 minutes), or +90 in an hour and a half |
||
DB_BACKUP_CLEANUP_TIME |
Value in minutes to delete old backups (only fired when dump freqency fires). 1440 would delete anything above 1 day old. You don't need to set this variable if you want to hold onto everything. | |
DB_BACKUP_MD5 |
Generate MD5 Sum in Directory, TRUE or FALSE |
TRUE |
DB_BACKUP_PARALLEL_COMPRESSION |
Use multiple cores when compressing backups TRUE or FALSE |
TRUE |
DB_BACKUP_SPLIT_DB |
If using root as username and multiple DBs on system, set to TRUE to create Seperate DB Backups instead of all in one. | FALSE |
The following ports are exposed.
Port | Description |
---|---|
3306 |
MariaDB Server |
For debugging and maintenance purposes you may want access the containers shell.
docker exec -it (whatever your container name is e.g. mariadb) bash
This image comes with Mysql Tuner. Simply enter inside the container and execute mysql-tuner
along with your arguments.
Manual Backups can be perforemd by entering the container and typing backup-now