How to use Docker for easy and fast WordPress development

A while ago I used to do my WordPress development using this “vagrant-based” environment. It’s very well written, opensource and comes with whatever you may need to create themes and plugins for WordPress.

But I wanted something lighter.

I needed a superlight WordPress installation, with no hassle and a very fast deployment. Docker Compose was the right choice.

  • Containers are lighter than a Virtual Machine
  • Containers are isolated but share the same OS and libraries (if needed)
  • If needed, the same docker-compose.yml file can be used for development and production, making environments compatible at a higher level.

So, here’s my docker-compose.yml file, for you to use.

You can also clone it from GitHub, if you want.

Let’s dig into this a bit…

First line: we’re telling docker which syntax version we’re going to use in the rest of the file. You can read more about the different versions on the docs.

Then in the services section we’re telling the system we need these images:

  • MySQL version 5.7, with some “strong” credentials 😛
  • WordPress, latest version

For WordPress, we’re telling the WordPress image to map the port 80 to our 8000, and to map the local wp-content folder to the same folder in the WordPress installation.

We’re going to put all our code in that folder, in order to make it available in the WordPress admin panel (think of themes and plugins).

So, to be up and running all you have to do is:

Open your browser. go to http://localhost:8000 and you’re good to go!

Easy, isn’t it?

If you want to share a comment or report an issue with this post, please send me an email to napolux@gmail.com

Share on: Twitter, Facebook, Reddit, Hacker News or go back home.