Buy Percona ServicesBuy Now!

Playing with Percona XtraDB Cluster in Docker

 | June 30, 2015 |  Posted In: Docker, High-availability, MySQL, Percona XtraDB Cluster, Quality Assurance, XtraDB Cluster


Like any good, thus lazy, engineer I don’t like to start things manually. Creating directories, configuration files, specify paths, ports via command line is too boring. I wrote already how I survive in case when I need to start MySQL server (here). There is also the MySQL Sandbox which can be used for the same purpose.

Playing with Percona XtraDB Cluster in DockerBut what to do if you want to start Percona XtraDB Cluster this way? Fortunately we, at Percona, have engineers who created automation solution for starting PXC. This solution uses Docker. To explore it you need:

  1. Clone the pxc-docker repository:
    git clone
  2. Install Docker Compose as described here
  3. cd pxc-docker/docker-bld
  4. Follow instructions from the README file:

    a) ./ 5.6    ( takes a PXC branch as argument, 5.6 is default, and it looks for it on

    b) Optional: docker-compose build (if you see it is not updating with changes).

    c) docker-compose scale bootstrap=1 members=2 for a 3 node cluster

  5. Check which ports assigned to containers:

    Now you can connect to MySQL clients as usual:
  6. To change MySQL options either pass it as a mount at runtime with something like volume: /tmp/my.cnf:/etc/my.cnf in docker-compose.yml or connect to container’s bash (docker exec -i -t container_name /bin/bash), then change my.cnf and run docker restart container_name


  • If you don’t want to build use ready-to-use images
  • If you don’t want to run Docker Compose as root user add yourself to docker group
Sveta Smirnova

Sveta joined Percona in 2015. Her main professional interests are problem solving, working with tricky issues, bugs, finding patterns that can solve typical issues quicker and teaching others how to deal with MySQL issues, bugs and gotchas effectively. Before joining Percona Sveta worked as a Support Engineer in the MySQL Bugs Analysis Support Group in MySQL AB-Sun-Oracle. She is the author of the book "MySQL Troubleshooting" and JSON UDF functions for MySQL.


  • Hi Sveta,

    I got error like this:

    docker-bld$ docker-machine ssh default
    ## .
    ## ## ## ==
    ## ## ## ## ## ===
    /”””””””””””””””””\___/ ===
    ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
    \______ o __/
    \ \ __/
    _ _ ____ _ _
    | |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
    | ‘_ \ / _ \ / _ \| __| __) / _ |/ _ \ / __| |/ / _ \ '__|
    | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
    |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
    Boot2Docker version 1.9.1, build master : cef800b - Fri Nov 20 19:33:59 UTC 2015
    Docker version 1.9.1, build a34a1d5
    docker@default:~$ ls
    docker@default:~$ ls /
    bin/ dev/ etc/ home/ init lib/ lib64 linuxrc mnt/ opt/ proc/ root/ run/ sbin/ sys/ tmp usr/ var/
    docker@default:~$ exit
    docker-bld$ docker-compose scale bootstrap=1 members=2
    WARNING: The RANDOM variable is not set. Defaulting to a blank string.
    ERROR: Couldn't connect to Docker daemon - you might need to run
    docker-machine start default`.

    Would you please give some advice here ?

  • Please ignore previous comment.
    Here is the output of
    $docker-compose build

    WARNING: The RANDOM variable is not set. Defaulting to a blank string.
    Building bootstrap
    Step 0 : FROM centos:centos7
    —> ce20c473cd8a
    Step 1 : MAINTAINER Raghavendra Prabhu
    —> Using cache
    —> 99ffa239711d
    Step 2 : RUN curl -s > /etc/yum.repos.d/percona-dev.repo
    —> Using cache
    —> 9633aa93213c
    Step 3 : RUN yum install -y
    —> Running in a57b46a572a8
    Loaded plugins: fastestmirror

    File contains no section headers.
    file: file:///etc/yum.repos.d/percona-dev.repo, line: 4
    ERROR: Service ‘bootstrap’ failed to build: The command ‘/bin/sh -c yum install -y’ returned a non-zero code: 1

    The “” in Dockfile is no longer valid, how to fix it ?

  • Tony, I am sorry for the delay in answer. I contacted with original maintainer of this Docker image asking to check how this issue can be fixed, but he is on travel now and we have to wait a little bit more when he is back. I will update you right after I have news.

  • First of all, I should note that, could run this only with CentOS 7.
    But there were some errors and I want to share workarounds.

    Change dev-repo link as it was changed:

    New should be similar to:
    RUN curl -s > /etc/yum.repos.d/percona-dev.repo

    Also change make command:

    from “RUN make -j$numcp” to “RUN make -j 1”

Comments are closed