10 Steps to Deploy WordPress Multisite Using Docker

By Stefan Thorpe
Deploy WordPress Multisite Using Docker via Caylent API

Our fourth Caylent API Tutorial is a complete step-by-step guide to creating a WordPress multisite install using Docker to realize High-Availability (HA). You can achieve this quickly by leveraging our Caylent API documentation on Postman. As ever, each of our in-depth tutorial posts come with an accompanying video tutorial on YouTube (see below). Discover just how simple the process is using our API collection to create as many WordPress sites as you require in a matter of minutes.


For this tutorial, you’re going to need:

To give you an idea of what we are building, our final cluster will look like a virtual version of the image below:

Docker WordPress Multisite Cluster

As depicted by the illustration above, we are creating a Docker Swarm autoscaling group that contains two worker nodes, and a separate self-healing group containing three masters. These will both use a shared Amazon Elastic File System (EFS), which as the name suggests, is a storage structure that scales on demand.

The Amazon EFS drive will store the Docker WordPress content, while we support the back end with a replicated version of a MySQL RDS database, and the front end will contain our Elastic Load Balancer (ELB).

So, set your Postman environment to Caylent API, login, and let’s begin!

1. Create a Generic Stack

As all of our tutorials demonstrate how incredibly straightforward it is to create a Caylent default Stack. Simply, click “POST 2. Create Docker Stack” to automatically build a stack made up of five instances, which by default includes three master servers and two workers.

All properties—including stack name, timestamp, etc.—are modifiable, though Caylent will autofill default data for each. Simply name your stack, e.g., “wordpress-multisite,” and hit “Send.”

The response will show that the stack status is still currently ”un-deployed.” We’ll need to add more services to it before we launch.

2. Add MySQL Database

Click “POST 3. Create Database” to attach a scalable relational database to the previously created stack for our Docker WordPress application to use. Postman will automatically store all response information contained within {{…}} (such as the necessary {{stackuuid}} for this step) unless you are following the process manually, in which case make a note of all these from the response body.

Remember, our Caylent API collections autofill a lot of these properties with default information to make your build process quick and straightforward. To tailor your install to your unique specifications, feel free to change parameters or any of the RDS settings that are also supported in CloudFormation.

Hitting “Send,” will attach the MySQL RDS database to the stack. Results will show in the response body.

3. Build EFS

Just select “POST 4.Create EFS” and click “Send.” No changes are required here. The command attaches the EFS to all stack nodes.

4. Stack Launch Process

Now that everything is configured, you are ready to launch your stack. Given the added MYSQL RDS database this will take roughly around 15 minutes to complete. Choose command “POST 5. Launch Stack” and hit “Send” to begin this process.

5. Create Mount

To do this, specify the mount target within the container as “var/www/html” with the default “{{efs}}/wordpress” source. This adjusts the necessary dynamic {{efs}} variable for the EFS file system, mounts the container to the EFS on each host in our system, and creates a WordPress folder to store all our primary persistent data within the EFS.

Hit “Send,” and you will later attach the mount to the stack after you configure your actual Docker WordPress multisite network container.

6. Create WordPress Multisite Container

Since there isn’t an official WordPress multisite container image, we have provided one. It is specified by default as the “image_uri“ : “caylent/wordpress-multisite” parameter.

Once again, Postman will input the required dynamic and environment variables from previous response body results such as the “database.host” and “database.name.” The image below shows the specifications for the default “number_containers” that we wish the service to run (i.e., 5), but you can change this according to your needs. Caylent requires an odd—rather than even—number of manager nodes to workers to maintain a tie-breaking consensus.

This step will prompt five containers to spin up once the install process is complete.

Postman WordPress Multisite Image

Hitting “Send” on command “POST 7. Create WordPress Multisite App” will attach the WordPress multisite image to our specified stack—which will still be deploying in the background.

7. Add Mount to Stack and Launch

The command “POST 8. Add Mount to App” attaches the previously created bind mount to our WordPress multisite application in a matter of seconds.

Next, we use the request “GET 9. WordPress Stack – Loop Until Deployed Copy.” Which, as it suggests, will run on a loop. Grab a coffee and catch a quick break while this completes, which is when the response body will register the state as “deployed.”

8. Deploy Docker WordPress Multisite Application

The penultimate step in our process is to click the command “POST 10. Deploy WordPress App to Stack.” This will only take a moment to complete once you hit “Send.”

Finally, we can use the request “GET 11. List All Nodes – Filter Stack” to list all the nodes, load balancer endpoints, and each node IP address.

8.5 Edit AWS Firewall Rules to Allow SSH Access (Optional)

If you want SSH access to this Stack, you’ll need to login to your AWS account to modify the inbound firewall rules. To do this, open the EC2 console and click on the relevant security group. Within the Security Group tab, select the “swarm-master-group” security group; click “Edit the Inbound Rules;” select “SSH” from the drop-down box selection; select “MY IP;” and hit “Save.”

AWS Firewall Inbound Rules

9. Configure Docker WordPress Multisite Setup

Due to the way WordPress works, the initial WordPress installation page is only available through one of the IPv4 Public IP addresses of one of our instances. You may need to cycle through each node IP address to find the correct one.

Run through the setup according to the prompts on the screen (see below) and hit “Install WordPress” when you are ready:

WordPress Setup Page


You should now be able to login with the details you’ve just created. You now have a fully functional WordPress website.

We now need to modify the WordPress DNS and alter it to our load balancer DNS. First, go back to Postman and the response body for Step 11 of the Postman API collection and copy the load balancer endpoint URL.

In the WP-Admin panel, navigate to Settings > General and paste the load balancer DNS address under “WordPress Address (URL)” and “Site Address (URL)” i.e., http://<your-ELB-DNS-address-here>.

If you’re running a fully qualified domain and that’s what you want WordPress on, then that is what you’ll switch out. While setting up though, Caylent recommends starting with the load balancer address until you complete your sites’ designs and add pages/posts.

Once complete, click “Save Changes” which should redirect you to your load balancer DNS address to log in again and open up your WordPress dashboard.

10. WordPress Multisite Network Setup

On your dashboard, choose Tools > Network Setup—which will be enabled—and you need to opt for “Sub-directories” from the choice available as you’re running your site from the load balancer. Just hit “Install.”

Caylent WordPress Multisite Demo

All that is left to do now is add the resulting information into your wp-config.php file within our target folder “/mnt/{{efs_uuid}}/wordpress/var/www/html” and replace the other WordPress rules for “.htaccess” too within your terminal.

Log back into WordPress, and creating new sites is as simple as clicking My Sites > Dashboard > Create a New Site followed by “Site Title,” “Admin Email,” and “Add Site.”

You can do this as many times as you like to add additional sites within WordPress.

Want to make this process even simpler? Check out Postman’s Collection Runner, and run this whole setup in just a few clicks.

Watch the full YouTube tutorial for this process here:

Keep an eye out for our next Caylent API Tutorial—coming soon!

Caylent provides a critical DevOps-as-a-Service function to high growth companies looking for expert support with microservices, containers, cloud infrastructure, and CI/CD deployments. Our managed and consulting services are a more cost-effective option than hiring in-house, and we scale as your team and company grow. Check out some of the use cases, learn how we work with clients, and profit from our DevOps-as-a-Service offering too.