A Nimble Docker Script to Provision WordPress Installs

There comes a time in every developer's life where they've tired of installing WordPress, editing their hosts file, typing npm install, and various other chores. There comes a point where every team member gets tired of figuring out what the other team member means by "everyone has to install SOAP on their systems". Well, a few months ago I had finally reached the point of no return. Docker was recently released, and the system appeared ready to make it possible for you to share your exact environment with your entire team. No worrying about installing soap for everyone on the team. No worrying that your version of php won't translate to the production server. There's just no worrying anymore! Docker is here, and though it is complicated and frustrating to work with sometimes, I've created a script that can (hopefully) tame the beast, give you a place to learn about it, and generally get you to the code faster.

The hardest part of beginning the Docker journey was setting up the first project. There are plenty of tutorials on various websites on "Starting with Docker", that make it seem like a piece of cake. "All you have to do is docker run $image!!" they say. Well, when it comes to provisioning environments that are relatively the same, but sometimes a little different, I found it hard to grasp all the interconnected pieces at times. So in order to spare you the overwhelming feeling of not knowing which of 20 different variables could be the problem, I'm going to provide you with a basic template, biased with WordPress, that will let you see Docker in action, and give you an idea of how it can be used to provision multiple websites for a local server.


Clone it, give it a try. I recommend cloning it somewhere in your User Directory on Windows or Mac. I've never tested it with Linux, but I assume it would maybe work. This script has some basic dependencies, like basename and other things that are generally installed on all systems. Also, it's a bash script, so your terminal needs to be based off of bash.

Now, if I'm honest, even just using this script could be complex. You will need to make sure Docker is working, that the Docker VM shares the drive your files are on, and if you're on Windows, you'll have to use the C:\ drive for Windows files if you'd like the hosts functionality to work. But moving from my work computer to my home computer, it only took about 5 minutes to install Docker and clone this script, so hopefully it works that way for you as well.

If you're able to create your first site with this script, from there you can go backwards. "What if I want to use PHP 7?" Change the image of wp_site under _projects/yourproject.yml. If everything breaks, you'll know that that one change broke everything. Hopefully, you'll never have to experience putting everything together for the first time and not knowing what went wrong, where, and hopefully this can provide a new foundation on which developers can get to the code faster.

As usual, use people's scripts at your own risk, etc. If it doesn't work, create an issue on Github, but this is a personal project so my ability to maintain it depends on my workload.