The easiest way to use Docker for WordPress Development

Note: I recently wrote a guest post on the WP Tavern about using Docker for WordPress development. In the post I talk about what Docker and Docker Compose is and how you can use them to create your WordPress development environment. The article on the Tavern is a more in-depth introduction to using Docker. Here, I just wanted to quickly share and walk you through the Docker Compose file I use for my setup while working on WP Pusher (Git for WordPress development).

Docker Compose

Docker Compose is a great tool for building and managing Docker containers. Here’s the Docker Compose configuration file I use to create a complete development environment for WP Pusher:

Here’s what’s going on in the file:

  1. I’m creating 2 services (Docker containers)
  2. One service is a MySQL database container
  3. The other service is the official WordPress container with Apache and PHP 5.6
  4. The WordPress container is forwarding port 80 to my local port 80, so I can access it directly in the browser without adding a port number
  5. The MySQL container is not port forwarding, but can easily forward to my local port 3306, so I can access the DB with SequelPro
  6. The database data is stored in a volume created by Docker on my local machine called wp_pusher_db_data
  7. The current working directory (the WP Pusher repository) is mounted in the plugins directory in the WordPress container

And that’s basically it. This will allow me to work on the WP Pusher plugin in a fully working WordPress environment, without installing WordPress, PHP or MySQL on my own machine.

Go check out the article on the Tavern here

WP Pusher – Git for WordPress

This post was brought to you by WP Pusher.

WP Pusher keeps all your client websites up-to-date whenever you push a change to GitHub or Bitbucket. Visit our website to learn more about WP Pusher.

git-for-wordpress

 

Want to read more like this?

Add your email address below to stay in the loop when new content arrives. You'll never miss a post.

Peter Suhm

Peter is a web developer from the Land of the Danes. He is the creator of WP Pusher and a huge travel addict.

 
  • Yeah, Docker is really cool. I just found it 2 weeks ago, and immediately realized how much better it has made my WordPress theme and plugin development environments. It just feels more enjoyable to do WP development somehow with Docker. I wrote up a tutorial about setting up Docker myself, for those who are interested: http://www.tenseg.net/archives/1819. Further, I go in to setting up Xdebug in the Docker containers and debugging PHP with Visual Studio Code.