Home

Awesome

MariaDB Docker Container Image

Build Status Docker Pulls Docker Stars

Docker Images

❗For better reliability we release images with stability tags (wodby/mariadb:11-X.X.X) which correspond to git tags. We strongly recommend using images only with stability tags.

Overview:

Supported tags and respective Dockerfile links:

Credits to Alpine Linux team for patches for better musl compatibility of MariaDB. Patches taken from Alpine's packages repository.

All images built for linux/amd64 and linux/arm64.

Environment Variables

Variable11.410.11, 10.6, 10.5
MARIADB_PLUGIN_LOAD
MARIADB_SSL_CERT
MARIADB_SSL_KEY
MARIADB_SSL_CA
MARIADB_TLS_VERSIONTLSv1.2,TLSv1.3TLSv1.2,TLSv1.3
MYSQL_BACK_LOG100100
MYSQL_CHARACTER_SET_FILESYSTEMbinarybinary
MYSQL_CHARACTER_SET_SERVERutf8mb4utf8mb4
MYSQL_CLIENT_DEFAULT_CHARACTER_SETutf8mb4utf8mb4
MYSQL_COLLATION_SERVERutf8mb4_unicode_ciutf8mb4_unicode_ci
MYSQL_CONNECT_TIMEOUT1010
MYSQL_DATABASE
MYSQL_DEFAULT_STORAGE_ENGINEInnoDBInnoDB
MYSQL_DUMP_MAX_ALLOWED_PACKET1G1G
MYSQL_GENERAL_LOG11
MYSQL_INIT_CONNECTSET NAMES utf8SET NAMES utf8
MYSQL_INNODB_BUFFER_POOL_INSTANCES--
MYSQL_INNODB_BUFFER_POOL_SIZE128M128M
MYSQL_INNODB_DEFAULT_ROW_FORMATdynamicdynamic
MYSQL_INNODB_FAST_SHUTDOWN11
MYSQL_INNODB_FILE_FORMAT--
MYSQL_INNODB_FILE_PER_TABLE-1
MYSQL_INNODB_FLUSH_LOG_AT_TRX_COMMIT22
MYSQL_INNODB_FLUSH_METHOD-O_DIRECT
MYSQL_INNODB_FORCE_LOAD_CORRUPTED00
MYSQL_INNODB_FORCE_RECOVERY00
MYSQL_INNODB_IO_CAPACITY200200
MYSQL_INNODB_LARGE_PREFIX--
MYSQL_INNODB_LOCK_WAIT_TIMEOUT5050
MYSQL_INNODB_LOG_BUFFER_SIZE8M8M
MYSQL_INNODB_LOG_FILE_SIZE128M128M
MYSQL_INNODB_LOG_FILES_IN_GROUP--
MYSQL_INNODB_OLD_BLOCKS_TIME10001000
MYSQL_INNODB_OPEN_FILES
MYSQL_INNODB_PURGE_THREADS44
MYSQL_INNODB_READ_IO_THREADS44
MYSQL_INNODB_STATS_ON_METADATAOFFOFF
MYSQL_INNODB_STRICT_MODEOFFOFF
MYSQL_INNODB_WRITE_IO_THREADS44
MYSQL_INTERACTIVE_TIMEOUT420420
MYSQL_JOIN_BUFFER_SIZE
MYSQL_JOIN_BUFFER_SPACE_LIMIT
MYSQL_LOG_WARNINGS22
MYSQL_LONG_QUERY_TIME22
MYSQL_LOWER_CASE_TABLE_NAMES
MYSQL_MAX_ALLOWED_PACKET256M256M
MYSQL_MAX_CONNECT_ERRORS100000100000
MYSQL_MAX_CONNECTIONS5050
MYSQL_MAX_HEAP_TABLE_SIZE16M16M
MYSQL_NET_READ_TIMEOUT9090
MYSQL_NET_WRITE_TIMEOUT9090
MYSQL_OPEN_FILES_LIMIT00
MYSQL_OPTIMIZER_PRUNE_LEVEL11
MYSQL_OPTIMIZER_SEARCH_DEPTH6262
MYSQL_OPTIMIZER_SWITCH
MYSQL_PASSWORD
MYSQL_PERFORMANCE_SCHEMAOFFOFF
MYSQL_PORT33063306
MYSQL_QUERY_CACHE_LIMIT1M1M
MYSQL_QUERY_CACHE_MIN_RES_UNIT2K2K
MYSQL_QUERY_CACHE_SIZE1M1M
MYSQL_QUERY_CACHE_TYPEOFFOFF
MYSQL_RELAY_LOG_RECOVERY00
MYSQL_ROOT_PASSWORD
MYSQL_SLOW_QUERY_LOG00
MYSQL_SORT_BUFFER_SIZE2M2M
MYSQL_TABLE_DEFINITION_CACHE400400
MYSQL_TABLE_OPEN_CACHE40964096
MYSQL_THREAD_CACHE_SIZE7575
MYSQL_TMP_TABLE_SIZE16M16M
MYSQL_USER
MYSQL_WAIT_TIMEOUT420420
MYSQL_TRANSACTION_ISOLATIONREPEATABLE-READREPEATABLE-READ
MYSQL_TRANSACTION_READ_ONLYOFF-

"-" - Not available for this version

Additional environment variables

MYSQL_INNODB_DATA_FILE_PATH:

Default value for all versions:

ibdata1:10M:autoextend:max:10G"

Additional Galera environment variables

VariableValue
WSREP_ONOFF
MYSQL_INNODB_FLUSH_LOG_AT_TRX_COMMIT0
WSREP_AUTO_INCREMENT_CONTROLON
WSREP_CERTIFICATION_RULESstrict
WSREP_CERTIFY_NONPKON
WSREP_CLUSTER_ADDRESS
WSREP_CLUSTER_NAMEmy_wsrep_cluster
WSREP_CONVERT_LOCK_TO_TRXOFF
WSREP_DATA_HOME_DIR
WSREP_DBUG_OPTION
WSREP_DEBUGNONE
WSREP_DESYNCOFF
WSREP_DIRTY_READSOFF
WSREP_DRUPAL_282555_WORKAROUNDOFF
WSREP_FORCED_BINLOG_FORMATNONE
WSREP_GTID_DOMAIN_ID0
WSREP_GTID_MODEOFF
WSREP_IGNORE_APPLY_ERRORS0
WSREP_LOAD_DATA_SPLITTINGOFF
WSREP_LOG_CONFLICTSOFF
WSREP_MAX_WS_ROWS0
WSREP_MAX_WS_SIZE2G
WSREP_MYSQL_REPLICATION_BUNDLE0
WSREP_NODE_ADDRESS0.0.0.0
WSREP_NODE_INCOMING_ADDRESSAUTO
WSREP_NODE_NAME
WSREP_NOTIFY_CMD
WSREP_OSU_METHODTOI
WSREP_PROVIDER_OPTIONS
WSREP_RECOVEROFF
WSREP_REJECT_QUERIESNONE
WSREP_REPLICATE_MYISAMOFF
WSREP_RESTART_SLAVEOFF
WSREP_RETRY_AUTOCOMMIT1
WSREP_SLAVE_FK_CHECKSON
WSREP_SLAVE_THREADS1
WSREP_SLAVE_UK_CHECKSOFF
WSREP_SR_STOREtable
WSREP_SST_AUTH
WSREP_SST_DONOR
WSREP_SST_DONOR_REJECTS_QUERIESOFF
WSREP_SST_METHODrsync
WSREP_RECEIVE_ADDRESSAUTO
WSREP_START_POSITION
WSREP_SYNC_WAIT0
WSREP_TRX_FRAGMENT_SIZE0
WSREP_TRX_FRAGMENT_UNITbytes
Galera Config DirectiveOverride
----------------------------------
binlog_formatROW
default_storage_engineInnoDB
innodb_autoinc_lock_mode2

Galera Cluster

Galera Cluster Documentation

In-depth documentation about Galera would be too lengthy for this README file. Instead, refer to these authoritative documentation sources:

When these sources disagree (for example, wsrep options/system vars are slightly different), favor MariaDB's documentation over Codership's.

Galera-specific MariaDB configuration

You must set the WSREP_ON environment variable if you want the container's /etc/mysql/my.cnf to include Galera/wsrep specific configuration settings.

Bootstrapping a Galera Cluster

When starting a new cluster, the first node must bootstrap the cluster:

$ docker run -e WSREP_ON=ON -v data1:/var/lib/mysql --name galera-1 \
    wodby/mariadb:galera --wsrep-new-cluster

When the first node is ready, the other nodes can join it (via its hostname or IP) and participate in the cluster:

$ docker run -e WSREP_ON=ON -v data2:/var/lib/mysql --name galera-2 \
    wodby/mariadb:galera --wsrep-cluster-address="gcomm://<node-1>"
$ docker run -e WSREP_ON=ON -v data3:/var/lib/mysql --name galera-3 \
    wodby/mariadb:galera --wsrep-cluster-address="gcomm://<node-1>,<node-2>"

After the other nodes have joined the first, you should terminate the first container and docker run a new container without the --wsrep-new-cluster and join the other nodes. This is to prevent cluster re-bootstrap if the bootstrap container (or the host it's on) ever decided to restart.

You may also want to restart the second node with a --wsrep-cluster-address=gcomm://<node-1>,<node-3>, or if you know all three node hostnames or IPs ahead of time, you can use gcomm://<node-1>,<node-2>,<node-3> for all node containers.

Using Galera Arbitrator Daemon for Small/Even Clusters

For Galera clustering to work properly, it requires a quorum of nodes to agree on pending commits.

Although a one-node cluster is possible (it will always agree with itself), the minimum number of "voters" to achieve quorum is 3. A two-node cluster is possible, but you must add a Galera Arbitrator Daemon (aka garbd) as add a third voter. In general, it's a good idea to use garbd for clusters with even numbers of nodes, to provide a tie-breaking vote in case half of the nodes agree and the other half disagree.

The galera-tagged images also include garbd, which can be run instead of mariadb.

$ docker run wodby/mariadb:galera garbd --help
Usage: garbd [options] [group address]
[...]

Refer to the documentation for configuration details.

Orchestration Actions

Usage:

make COMMAND [params ...]

commands:
    import source=</path/to/dump.zip or http://example.com/url/to/dump.sql.gz> [db root_password host ignore="table1;table2;cache_%"]
    backup filepath=</path/to/backup.sql.gz> [root_password host db]
    query query [db user password host]
    query-silent query [db user password host]
    query-root query [db root_password host]
    check-ready [root_password host max_try wait_seconds]
    mysql-upgrade [root_password host]
    mysql-check [root_password host db]
    create-db name [charset collation]
    drop-db name
    create-user username password
    drop-user username
    grant-user-db username db
    revoke-user-db username db

default params values:
    user $MYSQL_USER
    password $MYSQL_PASSWORD
    db $MYSQL_DATABASE
    root_password $MYSQL_ROOT_PASSWORD
    host localhost
    max_try 1
    wait_seconds 1
    ignore ""

Deployment

Deploy MariaDB to your own server via Wodby Wodby.