Simplified WordPress Development with Docker Compose

Harald explains, how a developement environment for WordPress is created with Docker Compose: for new and existing projects as well as for plugins/themes.

by Harald Nezbeda
Reading time 6 min
Harald N web
Software Development
Harald N web

Development environments are essential in order to bring new software to life. Each technology has a specific set of tools that can be used to create such an environment, and so does web development. In the early days, we used web server solution stacks such as XAMPP or a virtual machine, where everything was installed manually. In the best case those virtual machines could be exported as a template. By applying custom scripts on these templates, the automatic installation of specific packages was possible. To make our lives easier, we used Vagrant for this, which made it comfortable to share the development environment for a specific project to all the developers involved. But it takes quite some time to create the scripts and also the runtime and the memory usage are limited (because this system is using VirtualBox). Also it is time-consuming to create multiple instances of the boxes and connect services between them. But there is a great solution to it: This is where Docker comes into play. By using Docker the scripts for creating the environments are easier to read and maintain, and it gives you the possibility to work on docker images created by previous scripts (core images can be created and the docker files are lighter). The final piece in this puzzle is Docker Compose. This package allows the creation of a configuration file where all the commands that usually run in the console can be written in a more readable and expandable way. It also gives you the possibility to connect containers. This is how we can create components that are responsible for only one purpose: web server, database, emails and so on. Using this power we can establish an easier workflow for WordPress projects, e.g. developing a plugin, a theme or even an entire new project based on WordPess. For this, we are going to use WPDC (WordPress Docker Compose): You can find it here in my GitHub directory.