Docker file/image to deploy Percona XtraDB Cluster 5.6 for dev/tests.


$ git clone
$ cd docker/percona-xtradb-5.6/centos
$ ./
$ ./ 3
$ ./
$ ssh root@ (root123)
$ mysql -uroot -proot123 -e "show status like '%wsrep%'"

Percona XtraDB Cluster 5.6 Dockerfile

# Percona XtraDB Cluster 5.6
# tag: latest
FROM centos:latest

RUN yum -y update
RUN echo 'root:root123' | chpasswd
RUN yum -y install openssh-server openssh-clients which
# unsafe
#RUN sed -ri 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config
RUN mkdir -p /root/.ssh; chmod 700 /root/.ssh
ADD /root/.ssh/authorized_keys
RUN chown root.root /root/.ssh/*; chmod 600 /root/.ssh/*

# supervisord for sshd
RUN yum -y install python-setuptools
RUN easy_install supervisor
ADD supervisord.conf /etc/
RUN chown root.root /etc/supervisord.conf

# epel
RUN wget
RUN wget
RUN rpm -Uvh epel* remi-*

# PXC XtraDB 5.6
RUN rpm -Uhv
RUN yum -y remove mysql-*
# need epel for qpress
RUN yum -y install Percona-XtraDB-Cluster-56 qpress
RUN rm -rf /var/lib/mysql/* /var/run/mysqld/* /etc/my.cnf
ADD my.cnf /etc/my.cnf
RUN chown mysql.mysql /etc/my.cnf

# sysbench need libaio and libmysqlclient
RUN yum -y install libaio
RUN wget
RUN rpm -Uvh sysb*
RUN rm -f *.rpm

EXPOSE 22 80 443 3306 4444 4567 4568

ADD /opt/
RUN chown root.root /opt/
CMD ["/bin/bash", "/opt/"]

This docker file creates an image with the most recent Percona XtraDB Cluster 5.6 package installed.
Each launched image starts a single bootstrapped Galera node. A launched image will check
if the MySQL server's data dir needs to be initated or can be re-used.

Run the script to bootstrap a cluster.
The script sets a proper wsrep-cluster-address for all instances named 'galera-N'
and then performs a rolling node restart of the DB nodes to join the cluster.

Build a docker image

The default root user and MySQL server root password is 'root123'.
Ports exposed: 22 80 443 4444 4567 4568

Before creating the image, tune the my.cnf file to your liking.


$ git clone && cd docker/percona-xtradb-5.6/centos
$ ./


$ git clone && cd docker/percona-xtradb-5.6/ubuntu
$ ./

$ docker images

alyu/ubuntu         pxc56               d440fdc4dffc        4 days ago          566.3 MB
alyu/centos         pxc56               01eb2d9512be        4 days ago          1.059 GB

Start 3 db instances

Launch 3 images named 'galera-1', 'galera-2', and 'galera-3' and map the host's
/mnt/data/{centos-pxc56|ubuntu-pxc56}/mysql to the instance's /var/lib/mysql direcory.

$ ./ 3

$ docker ps

CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                                                             NAMES
7349a81d2294        alyu/centos:pxc56   /bin/bash /opt/init.   4 seconds ago       Up 2 seconds        22/tcp, 3306/tcp, 443/tcp, 4444/tcp, 4567/tcp, 4568/tcp, 80/tcp   galera-3
862280f54f62        alyu/centos:pxc56   /bin/bash /opt/init.   4 seconds ago       Up 3 seconds        22/tcp, 3306/tcp, 443/tcp, 4444/tcp, 4567/tcp, 4568/tcp, 80/tcp   galera-2
bcb8ea7da6c3        alyu/centos:pxc56   /bin/bash /opt/init.   4 seconds ago       Up 3 seconds        22/tcp, 3306/tcp, 443/tcp, 4444/tcp, 4567/tcp, 4568/tcp, 80/tcp   galera-1

Bootstrap the Galera cluster

Sets a proper wsrep-cluster-address in each node's my.cnf file and performs a rolling restart
of the nodes so that they join the cluster.

$ ./

Login to the first node and check the cluster status

$ ssh root@ (pass: root123)
$ mysql -uroot -proot123 -e "show status like '%wsrep%'"


Add new comment

Plain text

  • No HTML tags allowed.
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link]( "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.