photo of desks in front of windows

An Introduction to WordPress and Docker

If you work in software, IT, or DevOps, you’ll have heard of Docker. But you’d be forgiven for not being overly familiar with it. Docker has recently taken over the container ecosystem and is increasingly a core part of developer operations and IT management in larger companies.

But what has it got to do with WordPress?

Well, as you know WordPress as a project is huge. It powers over 40% of the internet. And W3Tech estimates that “every two minutes, another top 10m site starts using WordPress.” But WordPress, despite its legions of fans, primarily uses patterns from previous iterations of how web apps, sites and servers were managed.

With its legacy, WordPress itself is a great fit for open source project containerisation. Though, many developers confess to now having a good understanding of how to work with it or maximise its capabilities.

As WordPress is making more in-roads to enterprise and large-scale deployments, Docker and similar containerisation technologies are becoming an essential tool. But where does WordPress fit in this rapidly expanding world?

What is Docker?

Essentially, Docker is a platform for developing, shipping, running and managing applications that have been split up into loosely isolated containers.

Each container is a single piece of the overall software required for your application so that it can run on its own. Broadly speaking, a container should represent one dependency or function of your application.

A great example is the traditional LAMP stack (Linux, Apache, PHP, MySQL). You may have separate containers for Apache, PHP and MySQL. Now that they are separated, a system but in PHP won’t stop your Apache process so some functionality can continue until the PHP process is fixed, The same with MySQL.

Crucially, Docker allows you to create and ship containers that are the same to all environments. Removing “It works on my machine”. Not because the environments have been set up to match, but because they are the same environment.

Why is Docker so interesting?

The benefits of Docker are plentiful, but it’s best to outline the advantages based on who’s using it:

Technology Leaders

Docker is great for tech leaders because it keeps the cogs turning smoothly. It improves developer workflow as it reduces lead time from idea to product. By separating concerns further, it improves security. 

And where single responsibility containers are concerned, they can be deployed to add capacity when needed whilst improving scalability in the long run.

Developers

Having closer matches between production, staging and development environments significantly improves developer productivity. 

Tooling for testing, building and managing containers is more and more mature every day, and generally, it’s easier to work with than Virtual Machines.

For DevOps and SysAdmin

A big win? Deploying builds is easier than ever when you’re including all of the dependent software in the deliverable. Plus, healing and monitoring are made easier as dying containers can be swapped out effortlessly for a new one.

How to bring WordPress and Docker together

Before we discuss how to bring them together, it’s important to understand why WordPress is the ideal candidate for containerisation (and thus, Docker). 

WordPress uses multiple components to run: a webserver, SQL database, PHP processes, a file server and potentially an object cache like Redis or a load balancer.

But many of WordPress’s instances are large and require scaling architecture. When a site runs on multiple machines, Docker can simplify the scaling.

As WordPress runs some of the biggest sites in the world, it needs to be able to provide multiple environments. These include build, testing, QA, staging and production. All of these can be achieved, with that all-important ease, thanks to Docker.

Docker’s flexibility means that matching environments to developers is effortless. And seeing as most websites are frequently worked on by many developers, Docker is often our container of choice.

Our Docker series is released monthly. If you’d like to learn more about Docker, sign up for our newsletter to know when our next part is live.

Stewart Ritchie Lead developer and founder of Powered By Coffee. Stewart has been building websites for 15 years and focusing on WordPress for 5. He founded Powered By Coffee in 2011 after finishing is masters degree. He lives in Guildford Surrey with his wife Sydney and their two cats.

Signup to our mailing list