Docker for WordPress MultiSite development

WordPress MultiSite (formerly known as “WordPress-MU”) is a built-in feature of WordPress that allows you to securely host many WordPress sites on the same code and database. It was developed for, one of the highest traffic web sites in the world.

Docker Compose provides rapid, dependency-free development of complex web applications by utilising the Docker container technology.

By using these two tools together, we can compose powerful new site networks catering to different verticals and communities around the world.

TL/DR: Head to this github repo and follow the instructions in the README for a fluid, MultiSite-capable development environment with no dependencies outside of Docker.

[github repo=”gravityrail/wordpress-docker-compose-example”]

[github repo=”gravityrail/wordpress-docker-dev”]

Why should MultiSite matter to you? Let’s imagine you spot a business opportunity providing tailored websites to a particular vertical – Research Institutes in Brazil, for example. With WordPress MultiSite you could create a SaaS business called “”, based on a customized WordPress installation specialized to that market.

WordPress provides a robust and well-documented core, and you just add the billing, custom themes & plugins, physical or cloud infrastructure, and whatever support your customers need.

Bonus: Many of the customisations you want to add will already be available via WordPress’ huge plugin and theme directories.

To see this model in action check out, a massive network of blogs for teachers and students created by the talented folks at, authors of the ultimate guide to MultiSite.

Another heavy user of MultiSite is BBC America, and HappyTables for restaurant and bar sites.

Since joining Automattic two weeks ago, I’ve been on a quest to create the perfect WordPress development setup, but my previous efforts didn’t work with MultiSite because PHP’s built-in web server has no URL Rewrite support. That’s why this week I’m updating my Docker image to use Nginx + PHP-FPM, so I can design my first Blog Network,

The caveat

Firstly – the same caveat as last time – this image is definitely not for production use! The only way to share files with your desktop using Docker volumes is to run the server processes as the root user.

For production, use either the official WordPress Docker image or deploy on a standard WordPress-compatible web hosting environment like Dreamhost or Hostgator. Or, if you really want unlimited scale, on WordPress VIP!

How the image is built

The most important way in which the image has changed from the previous iteration is swapping out PHP’s built-in web server for Nginx and PHP-FPM (FastCGI Process Manager). This combo – unlike Apache – can be run as the root user, allowing the Docker container and local development machine to both write to the same filesystem.

For nginx, we changed the line “user www-data” to “user root” in /etc/nginx/nginx.conf.

For PHP-FPM, I changed the user, group, listen.user and listen.owner values to be “root”.

Another major change was adopting supervisord as the main process, so that we can run both nginx and PHP-FPM on the same container. Docker containers don’t “boot” like a regular VM, therefore process orchestration must be done by hand rather than relying on /etc/rcX.d.

We also added an nginx configuration file for the site, based on the official WordPress Nginx instructions for subfolder-based MultiSite.

How to use it

To get up and running, check out this github repo with a sample configuration file, then follow the instructions in the README.

Once you’ve done that, you can enable MultiSite like this:

docker-wp core multisite-convert --title="My Blog Network"

Then in a shell run open "http://$(boot2docker ip):8080/wp-admin/network" to configure the site network, or continue to use the awesome wp-cli to make changes.

That’s it!


Further reading:

One Reply to “Docker for WordPress MultiSite development”

Leave a Reply

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