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 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:
- I’m creating 2 services (Docker containers)
- One service is a MySQL database container
- The other service is the official WordPress container with Apache and PHP 5.6
- 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
- The MySQL container is not port forwarding, but can easily forward to my local port 3306, so I can access the DB with SequelPro
- The database data is stored in a volume created by Docker on my local machine called wp_pusher_db_data
- 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.
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.