Docker Compose for Local WordPress Development
Using Docker Compose for Local WordPress development is an excellent way to get up and running with WordPress development as quickly as possible.
Benefits of Using Docker Compose for WordPress Development
Traditionally, developing WordPress locally means that you must have PHP, MySQL, and Apache (or some other web server) installed on your local workstation. The complexity of installing and configuring these tools varies by the operating system. Furthermore, you may quickly find yourself in configuration hell attempting to configure new releases of WordPress, PHP, MySQL, or Apache.
Luckily, Docker and Docker Compose remove all of the guesswork from installing, configuring, and upgrading these tools. For example, upgrading to a new version of MySQL with Docker Compose is as simple as changing a single value in a single configuration file.
FROM:
image: mysql:5.7
TO:
image: mysql:8.0
Getting Started with Docker Compose
You can start using Docker Compose for local WordPress development with four steps.
Install Docker Locally
First, make sure that you have Docker installed on your workstation. You can verify that everything is working properly by opening up a terminal and running a few commands.
Note for Windows Users
By default docker and docker-compose are not in the Windows PATH variable. For these commands to work, be sure to add C:\Program Files\Docker\Docker\resources\bin to the PATH.
Executing docker version should produce output that looks like this:
Windows Terminal
PS C:\Users\Lev Lazinskiy> docker version
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:23:10 2020
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:29:16 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Executing docker-compose version should produce output that looks like this:
Windows Terminal
PS C:\Users\Lev Lazinskiy> docker-compose version
docker-compose version 1.25.4, build 8d51620a
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c 28 May 2019
Create a Project Directory Structure
Next, create an appropriate project directory structure. We’re going to mount our local project directory to a running instance of a WordPress docker container. To keep things simple, create a new directory called wordpress with the following directory structure.
PS C:\Users\Lev Lazinskiy\git\wordpress> tree
Folder PATH listing
C:.
└───wp-content
├───plugins
│ └───my_new_plugin
└───themes
└───my_new_theme
As illustrated above, if you’re making a new plugin, the code for your plugin would go into the wordpress\plugins\my_new_plugin directory. Likewise, if you’re making a new theme, then the code for your theme would go into the wordpress\themes\my_new_theme directory.
Create a Docker Compose for Local WordPress Configuration File
The last step is to create a Docker Compose configuration file. In the wordpress directory from the previous step, create a new file called docker-compose.yml. This file should have the following contents:
version: "3"
services:
wordpress:
image: wordpress:latest
restart: always
environment:
WORDPRESS_DB_PASSWORD: wordpress
ports:
- "8080:80"
volumes:
- "./wp-content:/var/www/html/wp-content"
depends_on:
- mysql
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
ports:
- "13306:3306"
volumes:
- "./mysql-data:/var/lib/mysql"
A couple of things worth highlighting in this configuration are the ports and volumes directives on the mysql container. We’re exposing port 13306 so you can use a MySQL client to connect to the running docker instance. Since we’re mounting a local volume called mysql-data any changes you make will persist across reboots.
Lastly, since we’re mounting wp-content in the wordpress container, any changes that you make to your new theme or plugin will be immediately available in your local WordPress instance.
Note for Windows Users
In order for volume mounting to work correctly on Windows, you must enable File Sharing in the Docker settings.
Open the Docker app, navigate to Resources and then File Sharing. Make sure that your primary drive is selected. Select Apply & Restart.

Run Docker Compose
You should now be able to run docker-compose up and navigate to https://localhost:8080 to see your new WordPress site running locally.

If you see the page shown above, complete the installation as you would any other WordPress site. When you log in, you will see your new theme and plugin available to install.
The first time you run Docker Compose it will take some time to download the WordPress and MySQL base images. Subsequent restarts will be quicker since Docker Compose will use a locally cached image.
Conclusion
In summary, using Docker Compose for local WordPress development is a quick and easy way to hack on WordPress themes and plugins. This approach has the added bonus of not needing to deal with the complexity of installing PHP, MySQL, or Apache on your local machine.
Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.
Check out some more stuff to read down below.
Most popular posts this month
- 2024
- Reinstalling Windows at 1am
- SQLite DB Migrations with PRAGMA user_version
- My Custom Miniflux CSS Theme
- How to Disable Wayland in Debian Testing
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- The Software Essays that Shaped Me from Refactoring English
- Give Your Spouse the Gift of a Couple's Email Domain from mtlynch.io
- Skip the Next iPhone from Articles on Jose M.
- Have smart glasses finally hit an inflection point? from The Torment Nexus
- The McPhee method from the jsomers.net blog
- Pluralistic: LLMs are slot-machines (16 Aug 2025) from Pluralistic: Daily links from Cory Doctorow
- Pluralistic: Bluesky creates the world's weirdest, hardest-to-understand binding arbitration clause (15 Aug 2025) from Pluralistic: Daily links from Cory Doctorow
- Just a Little More Context Bro, I Promise, and It’ll Fix Everything from Jim Nielsen’s Blog
Articles from blogs I follow around the net
Pluralistic: Carl Hiaasen's 'Fever Beach' (21 Oct 2025)
Today's links Carl Hiaasen's 'Fever Beach': If you didn't laugh, you'd have to cry. Hey look at this: Delights to delectate. Object permanence: Scary Godmother; Nightvale novel; The war on Worker's Comp; Cadillac's murdermo…
via Pluralistic: Daily links from Cory Doctorow October 21, 202510 pointless facts about me
Found on Kev’s blog and originally started by Dave, here are my answers to this fun blog challenge: Do you floss your teeth? Sometimes. I’d say maybe a few times a week? I’m terrible at being consistent, and that includes flossing regularly. Tea, co…
via Manuel Moreale — Everything Feed October 21, 2025Getting started with simple CSS View Transitions
There's (yet another) new piece of CSS to learn! Hurrah! Way back in 2011, jQuery mobile introduced the web to page-change animations. Clicking on a link would make your high-tech Nokia display a cool page-flip as you navigated from one page of a web…
via Terence Eden’s Blog October 21, 2025Generated by openring