Using Percona Server 5.6 with the Docker open-source engine

There are a couple of posts about setting up Percona XtraDB Cluster on Vagrant and Percona Server on MySQL Sandbox – those are two of the top tools used by the Percona Support team for testing and bug processing among other things.

In this post, however, I will show you how to use Docker with Percona Server on Ubuntu 12.04.

As per Docker’s official site:

Docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self-sufficient container that will run virtually anywhere.

Docker containers can encapsulate any payload, and will run consistently on and between virtually any server. The same container that a developer builds and tests on a laptop will run at scale, in production*, on VMs, bare-metal servers, OpenStack clusters, public instances, or combinations of the above.

To install Docker on Ubuntu 12.04 you need to follow instructions from Docker’s official documentation:

After installing Docker, you may either download docker images via ‘docker pull’ and store docker images on your server so you can spin a new docker container in an instance or you may choose to do a ‘docker run’ on the terminal and implicitly download/store the specific docker image from and run the image afterward.

Let us create a CentOS docker container by running the following command:

As you may have noticed, we have just created a new interactive (-i) CentOS 6.5 docker container and ran bash in a single line of command. Detaching from the container is as easy as typing CTRL+p – CTRL+q, you’ll get to your terminal if you typed the right keys.

Verify the active containers:

To list all existing containers active or not use the following command:

To attach to the active docker container:

*Tip: Hit enter twice to get to the container’s bash prompt.*

Install Percona Server 5.6

Now that you have a working docker container you will then have to install the needed packages and repository.

There you have it, a freshly installed Percona Server 5.6.17 on CentOS 6.5 Linux container. Yay!

You can now create a new MySQL user to access the server outside the container:

We’re basically following installation instructions for Percona Server from the documentation.

Just the same way as you would do on any server, you can install other equally important Percona software on the same container to complete your docker environment.

As an added bonus, you can contribute to the Docker Community by commiting your container and pushing it to the docker registry.


I’ve shown you how easy it is to spin a docker container and install Percona Server 5.6 in it. This is by far one of the fastest ways to create test/staging environments to simulate production servers. For further reading you may want to read Docker’s official documentation here.

I hope that this has piqued your interest to try it out yourself. And if that happens we would love to know how Percona Server and other Percona software perform on your docker environment. Cheers!

Share this post

Comments (7)

  • Janos Feher Reply


    At Intern Avenue we have created a plain image based on CentOS and Percona

    or just execute “drush run -t internavenue/centos-percona”… Enjoy!

    June 23, 2014 at 12:39 pm
  • Michael Ferranti Reply

    Hi Jericho,

    Thanks for this tutorial! I found it looking for info about how people were running databases in Docker.

    I’d be curious to get your thoughts on an opensource project that we’re working on to simplfy the deployment and migration of databases like Percona running inside Docker containers:

    You could use Flocker to deploy your Percona cluster to multiple nodes and then migrate the containers and their volumes around if you needed to, for instance, upgrade the ram on your host.

    This is a 100% open-source project so I’d love to get your feedback on how we could make things easier for Percona users.



    July 7, 2014 at 6:56 am
  • Michael Reply

    Hi Jericho,

    Just wanted to follow up and let you know that we just released the first major point release of Flocker.

    Flocker handles multi-node deployment, container migration along with associated volumes, and container networking so you (usually) don’t have to update DNS after a database migration.

    The code is here (, and we put together a tutorial for deploying and migrating MongoDB ( We’re working on a MySQL sample as well and would love to support Percona too. 🙂

    Would love you thoughts if you have a minute.

    August 19, 2014 at 8:27 pm
  • Jericho Rivera Reply


    Thanks for taking the time to read this blog post!

    Flocker looks very interesting and I would try it out sometime soon. Interested to check out your tutorial for deploying and migrating MySQL/Percona, also would be good to know if it can handle multi-node deployment and migration of Percona XtraDB Cluster nodes.


    August 20, 2014 at 9:19 pm
  • Marcus Bointon Reply

    I thought you’d like to know that I created a Percona Server entry for the Dockerfile Hub project:

    This provides trusted, pre-built images for Docker, making it quicker and easier to build docker clusters.

    September 1, 2014 at 3:22 am
  • Vojtech Kurka Reply

    Jericho, thanks for the article.
    Do you please know if there’s a performance penalty when running mysqld using docker? I assume the performance should be the same, but I’m not sure, because I don’t know much about docker and OS interaction.

    Thank you, Vojtech

    October 1, 2014 at 11:19 am
  • Jericho Rivera Reply


    You might want to look at this research report conducted by IBM on the performance comparison of virtual machines and Linux containers which shows benchmarks run using SysBench OLTP run against a single instance of MySQL 5.5.37:$File/rc25482.pdf

    Now I would assume there would be significant performance penalties when you run multiple docker containers on a single host machine as each docker container will try to compete with each other for resources, unless you restrict them in cgroups.

    Please be aware though that this write-up is for test environments only, for production systems it would be a lot different and in fact it is not yet recommended (afaik) to use Docker in production.


    October 1, 2014 at 8:55 pm

Leave a Reply