Skip to content

Using Docker for WordPress Development

Using WordPress as a platform for your business website or blog is a great idea, in fact, we've posted before about Why you should use WordPress for your blog. WordPress is a great platform and it continues to evolve and is really easy to install. If you use a hosting provider to TSOHOST -UK Based WordPress Hosting you can install WordPress with just 1 Click and get started building your new WordPress website straight away!

This is really great, but it's not really the best way to go about building a website and it can have some real adverse business side effects if you're doing everything online! At some point you really should consider having a locally installed version of WordPress on whichever computer you use.

This will help you when you're evaluating Themes and Plugins or even just to help draft up your next killer blog post. You can play around with different formatting and layout options without affecting your live website.

Digital marketers, we will be working on a number of different projects at any one time. Each project will typically have its own unique requirements and target customers, requiring slightly different layouts, text formatting and Image combination and you will want to test these out before publishing them out to the public.

In situations like this having an isolated local version of WordPress available can be really handy.

In this post, we'll guide you through our process of using Docker for WordPress Development, and guide you through how to install it on your Ubuntu laptop.

What is Docker?

Docker is an Open-Source tool that allows developers to easily deploy their applications, by creating containers which can then be deployed anywhere

Check out our article What is Docker? we have even created an easy reference to guide to all the common terms used when talking about docker and we even have a tutorial to follow to help get you install docker on your Ubuntu laptop

Although we predominantly use Ubuntu, Docker runs on all popular operating systems so be sure to follow the instructions on the docker website on how to install it on your system.

Using Docker for WordPress Development

Docker removes a lot of this hassle and now makes it incredibly easy to get your environments configured usually taken only a few seconds. Saving a lot of time and frustration. Using a feature like Docker - Compose help to make your WordPress website maintenance tasks simpler!

What is Docker Compose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

If you want to learn more we recommend reading an overview of docker compose

Install Docker compose

If your Docker application includes more than one container - as is the case for WordPress ( web server and database running in separate containers) - building, running, and connecting the containers from separate Dockerfiles is cumbersome and time-consuming. Docker Compose solves this problem by allowing you to use a YAML file to define multi-container apps.

You can configure as many containers as you want, how they should be built and connected, and where data should be stored. When the YAML file is complete, you can run a single command to build, run, and configure all of the containers.

Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.

Docker compose

There are detailed instructions to on the docker compose website to ensure you have the latest version installed.

Install WordPress Via Docker Compose

Once you have Docker and docker-compose all setup, moving on to the next phase is really simple.

Quickstart: Compose and WordPress

These instructions are great if you just want to get a version of WordPress up and running on your machine. However, if you want to build a complete development environment you will need to extend the docker-compose.yml

Install phpMyAdmin with docker-compose

We'll enhance the standard WordPress docker-compose.yml by adding a phpmyadmin to help with basic database administration tasks.

We'll grad the official phpMyAdmin image. link it to our wordpress_db container with the name mysql, expose its port 80 on port 8080 of the host system, and finally sets a couple of environment variables with our mySQL username and password.


Map to a local file system

It is possible to store the document root for WordPress on the host filesystem using a Docker data volume to share files between the host and the container.

We will also map the WordPress file system to our local drive, in order to be able to carry both theme and plugin development.

The WordPress Docker container is configured to check if the root HTML  is empty or not when it starts and copies files there appropriately. i.e. /var/www/html


Using docker-compose to launch WordPress

To use the Docker-compose file, using the terminal window simply change directory to the folder that contains the docker-compose.yaml and use the command docker-compose up -d.

Once it's complete, you should be able to open a browser to browse http://localhost  and http://localhost:8080/phpmyadmin.

Other useful docker-compose commands:


Develop themes and plugins

It is possible to develop specific components for WordPress, like themes and plugins. All it needs is a proper configuration of Volumes in the docker-compose.yml file.

theme development


plugin development



You should have a full WordPress deploy up and running.

You should be able to use the same method to create different version installations of WordPress that you can use for testing purposes, just changing the WordPress version.

running Docker commands to create containers already simplifies application management, docker-compose takes it a step further and allows you to bundle multiple containers within a single working directory.

Latest posts by Gary Woodfine (see all)