Setup an AWS High Availability Docker WordPress Stack

Written by Stefan Thorpe
Setup an AWS High Availability Docker WordPress Stack

Our third Caylent API Tutorial examines how you can setup and deploy a highly available Docker WordPress stack leveraging our convenient Postman API documents. This tutorial covers the necessary steps to quickly—and easily—launch a stack on Caylent to host an AWS high availability WordPress site with Docker. As ever, we support each of our tutorials with a YouTube video to take you through the whole process screen-by-screen.


For this tutorial, you’re going to need:

The entire process should take less than five to 10 minutes.

Download the Caylent API collection, login to your Postman account, select the Caylent API environment variables, and we are ready to roll.

You can automate the entire process for each of our Caylent API collections in Postman using the ‘Collection Runner’. See the image below for an example:

Postman Collection Runner Image

Note: The API collection automatically saves all properties within “{{…}}” as an environment variable (e.g., the {{mountUuid}} in this step). When we attach the “mount_uuid” later, we simply need to specify the saved response variable {{mountUuid}}.

If you are doing the process manually, save this property somewhere safe.

Create a Caylent Docker WordPress Stack

Under the API How To Guides in Postman, click “POST 2. Create Docker Stack.” This automatically creates a default Caylent stack made up of five instances, which includes three master servers and two workers comprising a Docker swarm cluster.

By default, Docker Swarm workers are placed in an auto-scale group that can scale up to a maximum of ten.

Within Postman, default properties are set for each property but you can change any of the variables (i.e., stack name, timestamp, etc.). Now, hit “Send.”

The results will show that the stack status is still currently ”un-deployed” because it’s not yet launched and you are going to add other services to it first.

Attach a MYSQL Relational Database Service

The Caylent API Docs make it easy to attach and scale a relational database to your Docker WordPress stack. Simply click “POST 3. Create Database.” Postman will remember the {{stackuuid}} from the previous step or you can specify that manually based on the response body from Step 2.

Caylent auto-fills default specifications, but these can easily be modified according to your needs. You can specify parameters for disk size, disk type, as well as any other RDS settings that can be altered within CloudFormation. Hit “Send.”

This will attach the MYSQL RDS to the stack and display the details in the response body.

Create Elastic File System

The command “POST 4. Create EFS” leverages AWS’s Elastic File System (EFS) to create the necessary simple, scalable file storage which WordPress requires. This simple request notifies the Caylent system to attach the EFS to all nodes. The command also mounts the file system, allowing WordPress to access every file across all servers and containers.

Again, specify the required stack and hit “Send.”

The next step is to launch our stack, using the “Launch” command. This may take a few seconds to complete—until it does, it will remain in a “waiting” state.

Create Mount

While you are waiting for the stack launch to complete, you can configure and setup your actual WordPress application according to your needs.

This will first involve creating a bind mount to our shared folder by clicking “POST 6. Create Mount,” then specifying the source as our dynamic {{efs}} variable for the EFS file system and that we want to create a WordPress folder.

Our mount target is “var/www/html” and the default “source” is “{{efs}}/wordpress.” This mounts our container volume to our EFS volume on each host in the cluster. When the container is initially created it will store all persistent data (i.e., wp_content) inside the shared file system. We will attach this mount to our app later.

Now, hit “Send” again.

Configure Your AWS High Availability WordPress Application

Creating the actual WordPress container service is easy; just use the request “POST 7. Create WordPress.” By default, our WordPress Postman collection creates a service called “wordpress” appended with the current “timestamp”—though you can name the service anything.

We’re going to use the latest official WordPress image and indicate that it should be attached to the current stack—which is probably still deploying in the background. At this point, you can specify the “number_containers” the service needs to run. We want five; one per server, but you can choose any number you want according to your requirements and load.

Open up “ports” : [ 80:80 ] on the actual service to map through to your load balancers.

For the WordPress image, we need to specify the following database variables.

Postman WordPress Application Configuration

We can again use our dynamic variables to pull in the necessary secrets such as the “,” “,” and other required environment variables which were produced at the time of creating the RDS database.

If everything looks good, hit “Send.”

Attach Mount

Our next request “POST 8. Add Mount to App,” does exactly what it suggests and attaches the previously created bind mount to our WordPress application. It’s as simple as click, specify the saved variable “mount_uuid”: “{{mountUuid}},” and hit “Send.”

Everything is now setup within Caylent’s system, and we’re ready to rock and roll.

It’s now just a case of waiting for your Docker WordPress stack to be deployed, (“GET 9. WordPress Stack – Loop Until Deployed Copy”). Once this state registers as “deployed,” you can continue with the following steps.

Deploy Application

Within the command ”POST 10. Deploy WordPress App to Stack,” specify the necessary “{{stackUuid}}” to deploy the app to your required stack and hit “Send.”

Once deployed, you’ll see a display of all the results including “comments,” “time,” and the “app version.”

Finally, we’ll use the last request in the collection to “POST 11. List All Nodes – Filter Stack.” This will display all our node endpoints including the server IPs and load balancer address.

You’ll now have to check each server IP address within your chosen web browser to work out the one instance that the WordPress installation page is on. This is due to a quirk with how WordPress installation works in a high availability configuration. Simply rotate through each server IP until you find the WordPress installation console.

Note: It may take a minute or two for the config to deploy because it’s a reasonably large installation.

WordPress Site Setup

WordPress Setup Page

Once you’ve followed the steps involved in the “famous five-minute WordPress installation process,” the final step of our tutorial is to edit the WordPress Address and Site Address URL in “General Settings.” Change the load balancer DNS address i.e., http://<your-ELB-DNS-address-here>. This can be found under “endpoints” in Step 11 of the Postman API template.

Hit “Save Changes,” once that the URLs are changed. After a minute or two, the load balancer will become “InService.”

Enter your account details, login to WordPress, and you’re good to go!


Here’s the YouTube video to watch the entire tutorial:


Watch the newest Caylent API YouTube Tutorial now: Deploy Multisite WordPress on Docker via Caylent API

Coming soon in our Caylent API Blog Tutorials: 10 Steps to Deploy WordPress Multisite Using Docker

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.

Related Posts

The DevOps container management platform

  • Amazon AWS
  • Microsoft Azure
  • Google Cloud
  • Digital Ocean

Unlimited users. Unlimited applications. Unlimited stacks. Easily manage Docker containers across any cloud.

Get Started—Free!
%d bloggers like this: