Magento 2 Demo on Docker and Panamax

Panamax and Magento 2I had a question – is Docker useful to demonstrate Magento 2 progress? Magento 2 updates are pushed weekly to GitHub so the code is available, but is it useful making it easier for people to run the code? In practice what may be of more interest showing the installation steps used, knowing that they work. Please add a comment if you try it and find it useful.

Disclaimer: I work for eBay with the Magento team, but this post is my personal opinions.

Docker and Docker Hub

I have written a bit about Docker before, but one aspect I have not mentioned much before is the Docker image repository. This is a central public repository where images can shared for easier reuse between projects. (You can also have private repositories for use inside your own company.)

For example, I have created a Magento 2 build based on 0.1.0-alpha89 (currently the release level is hard coded into the script). The Dockerfile and instructions to build the image are on GitHub. The built image is available on the Docker repository. If you look under the ‘tags’ tab you will see ‘latest’ and ‘0.1.0-alpha89’ are both available. Once you have Docker installed, you can download this image using:

$ docker pull alankent/docker-magento2-demo-apache:0.1.0-alpha89

This release is a few weeks old, but is the same version I used in a previous post on Magento 2 progress with Composer.

I describe how to use this image below, but as much use may be to have a look through the Dockerfile and supporting shell scripts to see how it is put together. For example, Magento 2 is deployed using Composer and then I restore a database dump with a few products loaded up. (In the future a proper data loading script will be provided.) Right now, the reason to explore Magento 2 is more around the changes to the code base rather than the functionality.

Wiring it Together with Panamax

Panamax is currently running a competition to get people to create Docker templates using their tools. Nothing like a deadline to see how easy it is to deliver a project using new technology, so I decided to give it a go (and enter the competition as well). For me, so far it is a story of both good and bad experiences. (Note: the project describes itself as 0.2.0 – not production ready yet. So bad experiences are to be expected.)

Good news: Defining a template using Panamax was trivial once I had my Docker images.

Bad news: My personal experience so far is it is still a bit unreliable. The UI is done pretty well, but the web server stopped responding for me a number of times. I suspect it was because the default install on my Windows set up a Virtual Box VM with only 1GB and within that I was loading up Panamax, MySQL, and Magento 2. I cranked the memory up to 8GB and it seemed to work better, but I still had problems (e.g. sometimes a search would not respond).  (Note: as I write this there was a 6.1 earthquake overnight – so not sure if internet cable were affected. The whole house was shaking and I am an hour and a half away from the epicenter. I don’t envy those in the middle of it!)

One thing that got me confused for a bit was I needed to add my own Panamax repo under the ‘sources’ section – an issue I raised on GitHub got that cleared up quickly. (Positive note: I will say GitHub issues I have submitted have been responded to promptly, even on weekends.) This was a matter of going to the ‘Sources’ section (the middle column between ‘Applications’ and ‘Images’) and adding ‘alankent/panamax’. My saved template (magento_2_demo.pmx) was then available for search and installation.

When I searched for ‘magento’ I also noticed a Magento 1.X Panamax competition entrant by paimpozhil. That might be worth checking out as well. Mine is “Magento 2 Demo” (currently waiting for my pull request to be accepted).

Creating Your Own Template

One good experience is that it was pretty quick to use the UI to create my own template. The following is a quick run through if you want to try and create one yourself to see what Panamax is like. Note: The following is not a replacement for reading the Panamax documentation.

  • Create a new application – this will take you to the search page to look for templates and images. Enter a search term of ‘mysql’. Select the official ‘mysql’ image and run it. (Later, you could try and experiment using say Maria DB instead of MySQL.) The template will get named based on the first image you select, but you can rename it afterwards.
  • (What will happen next is the image installation will immediately start and fail. It then retries over and over again. There is no way to add an image at present without it starting to run immediately. So while it is running (and failing), perform the following steps. When I asked, I got an answer back referring to this as ‘flapping’ – an area they were thinking about still.)
  • Click the little magnifying glass icon next to the container name (only appears when the mouse comes near the name) to bring up a page showing details about the image. In particular click on the ‘expose port’ button and enter 3306 as the port number to expose, and then add a new environment variable called ‘MYSQL_ROOT_PASSWORD’ with a value of ‘admin’. Save your changes and you should see the SQL server start successfully after a short period. You should see the messages about InnoDB appearing on the log when it starts working.
  • Next, search for ‘alankent’ and select the ‘docker-magento2-demo-apache’ image from the list. Again, it will start immediately – in this case it will get stuck in a loop trying to connect to MySQL.
  • For this image, define a port binding of 80:80/tcp. This will expose port 80 of the container as port 80 to the outside world. Also add 3 environment variables ‘MYSQL_USER’ set to ‘root’, ‘MYSQL_PASSWORD’ set to ‘admin’, and ‘PUBLIC_HOST’ to be the host name of machine Docker is running on. (Magento will form URLs using this host name.) Finally, you need to add a link from ‘mysql’ to ‘mysql’ which will link the Magento and MySQL containers together. Towards the end of the process you should see it run a PHP installation script, followed by mysql (loading a dump script to get a few products into the database), followed by ‘apache –D FOREGROUND’. Once that starts up you are ready to go.

If it does not work immediately, you can try to the reload button which will destroy all the images and create them again. Note that the Magento image takes a while to start (a minute or two) because each time the container starts it wipes and recreates the database. (Obviously this is not a production image!)

Wiring it Together using only Docker

So how would this have been done without Panamax?

$ docker run –d –name mysql –e MYSQL_ROOT_PASSWORD=admin mysql
$ docker run -d --name magento2 -p 80:80 --link mysql:mysql \
    -e MYSQL_USER=root -e MYSQL_PASSWORD=admin \
    -e \

Panamax does additional things like restart servers automatically on failure, but at the end of the day Panamax is a UI the hooks onto Docker.

Is it useful for Exploring Magento 2?

So is this useful? It can be used to get Magento 2 up and running quickly without worrying about so many configuration settings. I loaded up a couple of jacket products to get something happening out of the box. (The image is not that polished yet – it is just a quick demo to get feedback to see if worthwhile proceeding with.)

You can get inside the container to have a poke around at the code and configuration files using nsenter. I would do this in combination with looking at the Dockerfile and shell scripts on GitHub.

To me this has been an interesting experiment, I have learnt a lot more about Docker and Panamax, but it is not yet clear to me if this is value for learning more about Magento 2 specifically. What do you think? (Hint – try the comment button below!)


  1. There is a Panamax competition going – all entries are now included with the Panamax distribution. So you can now just search for Magento to find the Magento 1 (not mine) and Magento 2 (mine) demonstrations via Panamax. See

  2. Hi Alan I have build a docker magento 2 image which only needs a single command to set up / run magneto2 very easily. Do check and rate this image

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: