Develop a local WordPress theme using Docker

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

A while ago, we learned how easy it could be to set up WordPress using Docker. However, this setup didn't allow for customization.
So let's have a look at how we could develop our WordPress theme using Docker.
As we could see before, all we needed was a docker-compose.yml file.
In our new setup, we want to include a themes folder without specific themes.
In the example case, we have one theme called fooserama.

Note: This will overwrite all themes, so you will lose any themes you already loaded in WordPress (including the default ones)
Next up, we have to change our docker-compose.yml file to reflect this data.
The first part we want to change is the volume part for the WordPress image. Before, this was set up like so:
wordpress:
volumes:
- wordpress_data:/var/www/html
And then in the volumes section, we had this:
volumes:
db_data: {}
wordpress_data: {}
What we want is to change the volumes for the WordPress image like so:
wordpress:
volumes:
- ./themes:/var/www/html/wp-content/themes
And we want to remove this link for the volumes so it will look like this:
volumes:
db_data: {}
If we reboot out the Docker image, we should have our custom theme available on the WordPress website.
docker-compose up -d

This same approach could be used to handle plugins or even uploads if you wanted to.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter