Deploying WordPress using a Stack Template

Watch out! This tutorial is over 2 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

We previously looked at bringing up a WordPress website using the App Templates on Today we will look at a much quicker way to do the same task, using a “Stack Template”.

A Stack Template is when the yaml file is docker-stack.yml rather than docker-compose.yml and contains multi-container definitions. The different “services” can be brought up on different hosts in the Docker Swarm (ie. A cluster of docker hosts running in “Swarm” mode). We are running 2 hosts in Swarm mode inside the school. Docker01 and Docker02. Students access the swarm via the web frontend

You can of course have multiple services in a docker-compose.yml file also, but those services will all run on the same Docker host.

Here’s what a docker-stack.yaml file would look like for a WordPress installation (2 services, using 2 container mysql:5.7 and wordpress:latest)

And students can access this via the web frontend under App Templates.

It’s crazy easy to bring a new WordPress instance using the Stack Template. You don’t even need to create Private Network or anything in advance!

Click on WordPress (Stack) and give your stack a name.

Then click Deploy the stack and you’re done. No seriously, that’s all there is to it. Your stack is up before you realise it, you just need to get it’s details so you know how to access it. The reason the process is so fast is because our stack also creates the required MySQL database container/service and provides the WordPress container/service with all the details it needs to connect. If you run through the WordPress setup later on you’ll see you aren’t prompted for any database details at all.. you are finished in no time!

Let’s get the details of our WordPress installation so we can get to that point asap.

Click on your stack in the list to see the details. We are particularly interested in the Services that have been brought up.

As you can see, our WordPress container is running on Port 80 (obviously) but is mapped to port 30016 on the host(s). We can now access our WordPress installation by visiting (or as we are using a stack in Swarm mode) on port 30016 (not port 80, important!)

Run through the setup now, you’ll be amazed how fast it is as you are no longer asked for database connection details. You can just get on with your web project!

Tip: If you were off campus you could still get to your WordPress by firing up a desktop VM inside XOA and using it’s browser.