Skip to main content

WordPress Docker

Recently I’ve spent a lot of time learning how to make plugins and themes for WordPress. To make this process easier, I’ve created a repository with everything needed to spin up a new instance of WordPress with a lot of good stuff along with it.

To make this process easier, I’ve created a repository with everything needed to spin up a new instance of WordPress with a lot of good stuff along with it. The setup is meant to be used in combination with the Remote – Containers extension for Visual Studio Code.

Here’s a summary of what you’ll get if you use the setup:

In addition to this, the setup adds:

  • PHP code linting and formatting based on the WordPress Coding Standards.
  • Preinstalled Node so that you can use the npx @wordpress/….
  • Xdebug automatically configured and ready to be used.
  • WP-CLI for managing your WordPress installation from the command line.
  • The extensions needed in VS Code to make Xdebug and linting/formatting work.

Usage

  1. Clone this repository to a local folder and make sure you have Docker and Docker Compose installed.
  2. Open Visual Studio Code.
  3. Make sure you have the Visual Studio Code Remote – Containers extension installed.
  4. Open the command palette and run the command Remote-Containers: Open Folder in Container
  5. Select the folder with repository you just cloned.
  6. Wait for it…
  7. Happy coding!

Thats it! You should now have a database server and WordPress running in separate containers. PHP linting and formatting adhering to the WordPress Coding Standard should just work. You can also run the default debug configuration in VS Code using Xdebug.

Visit your WordPress site at http://localhost:8000.

Debugging with Xdebug

The container has been configured to not run Xdebug when using PHP from the command line. This is to prevent it from being used when PHP-Sniffer is triggered, since it will drastically slow down the linter and the formatter.

Here’s how to start a debug session:

  1. Launch the debug configuration Listen for XDebug
  2. In the «Ports» pane in «Remote Explorer», enable forwarding of port 9000 (click the refresh arrow to make it appear)
  3. Enable breakpoints and have fun!

Note: When you stop the debugging session, make sure to disable forwarding of port 9000, or else the page will appear to hang.

Adding plugins and themes

If you’re developing a plugin or a theme and you have that project locally on your computer, just add them as volumes in the docker-compose.yml file below the wp_root volume, like this:

volumes:
  - wp_root:/var/www/html
  - /opt/dev/awesome-plugin:/var/www/html/wp-content/plugins/awesome-plugin

..assuming you have the plugin in the local folder /opt/dev/awesome-plugin.

Feel free to contribute by opening a PR on Github. Here’s the repository:

https://github.com/kimgrytoyr/wordpress-docker

Next steps

Here are a few things you can do:

2026

September

  • Note

    As quite evident by looking at my brand new reading page, I haven't read very much this year. Going forward I will do my very best to finish the books I'm currently reading and find some new exciting books to read. Currently only finished three, the goal is 10!

  • Note

    I just ordered a Fairphone 6+, Fairbuds and Fairbuds XL.

    I have an iPhone 17 as my daily driver, but I couldn't help but order this phone and headsets once I became aware it was a thing.

    My plan is to switch to all of these things, replacing my iPhone 17, AirPods Pro 3 and Bose QuietComfort Ultra. These will either be sold or given to someone who needs them.

    The initiative is great and their values even better. We need companies trying to counter the enormous pressure laid upon all of us to keep buying stuff all the time.

    I will post a thorough review of these items once I've used them for a while.

  • Tømmerneset rock carvings

2025

April

  • Note

    I will be posting changes to my website simply as notes tagged with changelog. This is the very first changelog of this site, and it summarizes the most important changes I've done since I started wiping the dust of this site in April this year.

    • I've added a Buttondown newsletter integration. Whenever I publish a new post on my blog, an email will be sent to my subscribers.
    • I've added a «Reply by email» button to all content. Do not hestitate to contact me if you have comments or feedback. Getting feedback is a big part of why I blog in the first place — I enjoy hearing from readers and being part of a thoughtful exchange now and then.
    • I've added a Search feature using Pagefind. It's not yet fully configured or customized, but it's working.
    • Added links to previous and next post, note and link.
    • Added a 404 page.
    • Reduced the size of uncompressed resources being loaded on the front page to 66 kB. Submitted a PR to be added to the 512kb.club website.
  • Our dog: Kento
  • Note

    This is the very first note on my new website. It's a GREAT note.

    It doesn't say much, but still – it marks the beginning of a new note-hosting era for this website.

  • Back to basics – again..