Deploying a WordPress Container On Cycle

With Cycle, it’s easier than ever to create and run your own private, bare-metal cloud. The real power of the platform, however, is just how painless getting a container deployed to your infrastructure is.

Setting Up the Database

For this demo we’ll be deploying two containers: a WordPress instance and a MySQL database, and then linking them together — all without opening a terminal. If you’re not already familiar, WordPress is sort of an all-in-one CMS/website builder used by millions of websites around the world. It’s extremely popular and a perfect candidate for containerization.

The easiest way to get container images into Cycle is via a Docker registry, such as Docker Hub — a massive container image repository, with hundreds of thousands of container images that are ready to be deployed. It just so happens MySQL and WordPress have official hosted images we can use.

WordPress requires a database, so let’s get started by importing a MySQL database container. Open up your Cycle dashboard and click ‘Environments’ and create a fresh one for us to deploy to.

Select “Deploy Containers” in the top right corner.

Choose a name (I chose db), and then click “Import New Image”.

UPDATE: The latest version of mysql (version 8) is no longer compatible with the default wordpress image. Therefore you can no longer use the latest tag. Change the tag in the box to be 5.7.22

Enter ‘mysql’ into the box to search Docker Hub automatically. The first image on the list should be the official one, so select that. Enter 5.7.22 into the tag field. Your image will take a minute or two to import, but when it’s done click ‘Select Image’. You’ll see volume setup here, so choose an appropriate size for your database, as you aren’t yet able to adjust the size after deployment.

Make sure you have a hostname filled in (should be automatic based on the name), keep the network ‘disabled’ and click ‘Create Container’.

The hostname is how our WordPress container will access the database. By keeping the public network disabled, we ensure that only other containers in our environment can access it, not anyone on the internet.

The last step is to set a root password and start our database. This image looks for an environment variable called MYSQL_ROOT_PASSWORD , so let’s set that up next.

Navigate to the ‘Config’ tab and click ‘Runtime’. Here you’ll find everything affecting how the container runs, including privileges and the commands/arguments that run when the container starts. These settings are disabled by default, so click ‘Enable’ and then ‘Add Variable’. In the left box, type MYSQL_ROOT_PASSWORD and in the right enter your secure root password of choice.

Don’t use ‘test’ as a real password Don’t use ‘test’ as a real password

Click ‘Save’. Now we can start up the database so it’s ready to go before we run our WordPress container. Click the start arrow in the top right, then head over to the ‘Instances’ tab to watch the magic!

Deploying WordPress

Our database is ready, now we need to deploy a WordPress instance and link them together. Go back to the environment and hit ‘Deploy Containers’ again. We’ll follow the same process we did for the database, just substitute out the MySQL image for a WordPress one.

Be sure to set public internet to Enabled, since we actually want people to visit our blog.

Connect Your Domain

You’ll see the option to select a domain from the list once the network type is set to Enabled. Another great feature of Cycle is the ability to completely manage your domains. To configure this, you’ll need to go to your registrar where you purchased the domain (such as GoDaddy, Google Domains, etc.) and set the nameservers to:

once that is done, head back over to the container deploy form and click Add New Domain. A simple, one input popup will appear. Add in your domain (i.e., etc. and then click Add. Your domain will be added, just not verified. We’ll verify it after we finish deploying the container.

Adding SSL/TLS Support

Adding auto-renewing SSL/TLS certificates to a container is very straightforward. The problem here is that the default WordPress image does not support it. I’ve written another post that details how to do it. It’s a bit more technical, but I also provide a pre-made image that you can replace the default one in this tutorial with (cycleplatform/wordpress). If you have selected that image, go ahead and check Enable Automated TLS/SSL and be sure the path is set to the default /var/run/cycle/tls — that’s it!

Once you’ve finished with that form, click Save. However, just like before, we need to add a couple environment variables to tell the WordPress container where our database is (and the password) before we can start it.

Go to ‘Config’ -> ‘Runtime’, and click ‘Add Variable’ twice. The first one we need is WORDPRESS_DB_HOST and the second is WORDPRESS_DB_PASSWORD. For the former, enter the hostname you set on your database container (mine was db). For the latter, enter whatever password you set on your MySQL environment variable.

That’s it… let’s fire it up! Click start, then head over to the ‘Instances’ tab once again.

Again, it may take a few seconds to start the container the first time. Again, it may take a few seconds to start the container the first time.

Beautiful, no errors! Let’s check it out. To find your domain, go back to the ‘Dashboard’.

There you have it, a WordPress instance with its own dedicated MySQL container, that isn’t even connected to the public internet. The last step is to set up your new blog, but I’ll leave that part up to you 😊.