Public | Automated Build

Last pushed: 14 days ago
Short Description
Dockerized MaxScale for Galera Cluster Backend. Based on
Full Description


Dockerized MaxScale for Galera Cluster Backend.
Can be used in combination with

Branches & Tags

There are 2 branches available, which feature MaxScale1 and MaxScale2 versions.

Since MaxScale1 is free to use, but MaxScale2 needs a license from MariaDB in some setups, I will keep the master branch with version 1.4.5 for now. This also applies to the :latest tag in Docker.

Version Branch Docker Tag
1.4.5 master latest
1.4.5 1.x 1
1.4.5 1.x 1.4.5
2.1.9 2.x 2
2.1.9 2.x 2.1.9


With default settings for a 3 server configuration with default ports:

docker run -d -p 3306:3306 -p 3307:3307 \
    --name maxscale \
    -e BACKEND_SERVER_LIST="db01.myserver db02.myserver db03.myserver" \
    -e MAX_PASS="myMaxScalePassword" \

Using docker-compose

Check parameters in docker-compose.yml and start with:

docker-compose up -d


    docker build -t toughiq/maxscale .

Build own static image

You can build your own static image of maxscale, so you dont have to put your backend servers and credentials every time at the run command. Be aware NOT to push this image into a public repository, since it contains your personal server/cluster credentials.

Create Dockerfile Example

    FROM toughiq/maxscale
    ENV MAX_PASS="yourMaxScalePassword" \
    SPLITTER_PORT=4407 \
    ROUTER_PORT=4408 \
    BACKEND_SERVER_LIST="maria01.db maria02.db maria03.db" \

    docker build -t mymaxscale .
    docker run -d -p 3306:4407 -p 3307:4408 mymaxscale

Environment Defaults

    MaxThreads for MaxScale to run.
    MaxScale User in the cluster.
    MaxScale User password for the cluster.
    Allow root access to the DB via MaxScale. Values 0 or 1.
    MySQL/MariaDB Port MaxScale is exposing with the READWRITE service.
    Since this results in less errors when connecting, we made this the default on port 3306
    MySQL/MariaDB Port MaxScale is exposing with the READCONN service.
    MaxScale CLI port.
    Default timeout setting of 600sec/10min. If you need connections to be open for longer, just increase this value to the duration needed. Value is in seconds.
    Number of persistent connections to the backend server. Defaults to `0` which means no persistence. Change to `non-zero` value to enable given number of persistent connections.
    If persistent backend connections are enabled, this is the timeout in `seconds`. After this period a connections is regarded as deprecated and will not be used again.
BACKEND_SERVER_LIST="server1 server2 server3"
    List of backend Servers MaxScale is connecting to.
    Port on which the backend servers are listening.
    Should SQL variables when using `readwritesplit` be routed to all nodes or just the master. Possible values `all` of `master`. Defaults to `all`
    Version 1:
    Version 2:

BACKEND_SERVER_LIST and MAX_PASS have to be set on each docker run or within docker-compose.yml, since we cannot use defaults here.

Service discovery with Docker Swarm 1.12

If the backend servers are running within a service controlled docker swarm you can start MaxScale also as service and let it autodiscover each DB node running within service my_db_service

    docker service create --name maxscale \
        --network myDBnet \
        --env DB_SERVICE_NAME=my_db_service \

This is done by querying the internal DNS service and processing the DNS round robin result to generate maxscale.cnf at startup.

Docker Pull Command
Source Repository