WordPress docker container on your local PC.

Reading Time: 5 minutes
wordpress docker container
Image by: http://blog.loadimpact.com/wp-content/uploads/2014/12/WordPress-Docker.png

I have been thinking this for a long time, but I didn’t have the time to realize it, but now I am done with it and I wanted to share my progress. Since the Linux containers is the next huge thing in administering test environments I really wanted to make a copy my blog locally and I wanted to use a wordpress docker container for that purpose.

In order to do this we are going to need a running wordpress site – hosted somewhere, a docker installation and a WP plugin called Duplicator.

Here’s the small plan of actions to do it:

  • Installing docker.
  • Making a package of your existing WP installation via Duplicator.  
  • Move the package to the wordpress docker container.
  • Run the installer. 
  • Fix what you’ve just fucked up. 

What is docker container in first place.

I see that there’s lot of confusion on what a container is, so I will try to explain it in the way that I understand it. Think of a container as of an extremely trimmed and minimized version of a Linux OS, running only the utilities that you need. Practically, it comes to serve in the same manner as virtualization would do, but having a lot of advantages over it – no hypervisor, no boot times for the OS, the component you run in a container has all you need and nothing more. Docker offers all these pre-compiled docker images for almost everything you might need, including wordpress.

Installing Docker.

I am not going to explain this, since it’s more of a docker related info. I would recommend you to visit Docker’s official page where there’s a short tutorial on how to do that including a lot of documentation for using docker.

Note: I am using Linux (Lubuntu) as host for the Docker container.

Running a wordpress docker container.

I had some confusion with this, in fact I thought every time I want to have to container up, I have to run it. Which is incorrect so here’s a small walk through in container management.

docker pull tutum/wordpress #this pulls the image of a wp instance on your machine
docker run -p tutum/wordpress #runs the image to start a container
docker ps #shows the container state
docker logs 

You run the commands in exactly the same order and this should start a running wordpress docker container on You might want to ensure everything is running smoothly, just check the log, if mySql was installed w/o errors and Apache is running, it’s all OK, for now.

See also  Learning Linux as a tester.

Once you have your container running you can bring it up/down and restart it with one of the following commands:

docker start/stop/restart <container-name>

If you have any more questions, I used this article as guide for doing it.

Creating a package of your existing site.

For this purpose we’ll use the plugin called Duplicator. Duplicator is a plugin that let’s you to make a backup of your site with all its existing assets – plugins, database, media, themes, etc and deploy it on an empty machine via install.php script that the plugin creates. I repeat empty machine, because I am almost sure you don’t need wordpress installed on your new host, it will be created by the script. Anyway, I would risk deploying it on an empty Ubuntu server for example since I am not quite sure if it will install the MySql, Apache and so on. That’s why, we use already existing infrastructure of a wordpress and we’ll just deploy the new site there.

So, on the plugin. When installed it will appear in your menu and when opened you will be prompted to create your first package. The screens are pretty straight forward so just navigate through them and when done you will have two files that you will need – installer.php file and an archive.


Now you need to download both these locally and put them into the wordpress docker container. Let’s say its name is “freddy”. using this installation, all your wordpress related files are stored in /app folder and that’s the place you need these two as well. You can easily do this by executing the following command.

# on host 
#navigate to the folder where files are stored, let's say Downloads
cd /home/Downloads
# move them to the container
sudo docker installer.php 20150920_mrslavchev_55fea6be6ce6a6567150920122950_archive.zip freddy:/app

#the format of this command is
#docker /path/to/file/on/host :path/to/file/on/guest

Once you have these, you have these don’t be to quick on running the installer ’cause you have couple more thing to do. First, make sure the installer.php file has executable rights. To me, it wasn’t a problem to give it 777 since it’s a local machine and I will only use it for testing purposes, but in your case you might need to consider something else. The second thing, we need to do is to eighter delete the wp-config.php or the whole directory content, besides the installer and the archive. Other wise the installer will complain cause “there’s another wp installation there already and bla bla bla”. To me, deleting the wp-config file worked well enough. So, executing commands to a container might be done in two ways.

See also  Creating RAM disc - Linux

First, you can execute command once via the exec command like this:

docker exec freddy ls -l

Or you could sort of log in or attach to the container:

docker exec -it freddy /bin/bash

And you can directly navigate within your container and do the rest:

rm wp-config.php
chmod 777 installer.php

That should do. Now, you can go to and run the installer. In order to proceed you will need to kknow the instance of your database, pass and user. If you don’t know them you can simply cat the wp-config.php(before deleting it) and see in there.

Fixing what we’ve fucked up.

Normally when you finish the installation, there’s couple of thing you’ll have to do.

The plugin itself will ask you to update your symlinks, which is good as well as deleting the installer and the package, to avoid security breaches.

In my case, the site loaded all well, but some of my plugins we’re broken. For example – w3cache got completely messed up and all my styles were fucked, I had to remove it in order to have the site looking normally. Also, Crayon Syntax Highlighter got completely broken, so I removed it, too. So, these are kind of expected things that might get broken, after you move the site. Of course I don’t think they are something serious and are probably fixable by cleaning their cache, but for my purposes that was just useless.

So, I hope this post was helpful and interesting, if you liked it don’t forget to comment and share it with your friends. Good luck 🙂

Please follow and like us:


Senior software engineer in testing. The views I express here are mine, they don't represent any position held by any of my employers. Experience in mobile, automation, usability and exploratory testing. Rebel-driven tester, interested in the scientific part of testing and the thinking involved. Testing troll for life. Retired gamer and a beer lover. Martial arts practitioner.

See also  Today we fight back against mass surveilance

More Posts - Website

Follow Me:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.