Note: I am not a Docker expert.
These are just my personal notes for my local WP development environment using WordPress x Docker x Fig.
Here’s the final and improved version of this which will take the pain out of setting up. Just run start.sh and then your WP instance is good to go:
So why did I try this?
I used to run Vagrant then, I took an arrow to the knee.
In my setup, and in most of my development cases, I only put the wp-content in repo with the exception of wp-content/uploads.
So the file system setup of the root directory is like this:
Here are the things that I did.
Install Docker, m*therfucker.
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
So a great person once told me that we need Fig for us to run the Docker easier. In short, a fig.yml basically just defines a Docker build & environment. Easier to read, easier to type.
The fig.yml is different for every instance. If your setup is, say you put the whole WP in the repo, you’ll probably end up having a different one.
Before running it
When you encounter a problem just “fig logs” and then check. Or, “fig rm” and repeat the “Actually running it” steps.
As you can see, there aren’t any Dockerfile in this tutorial because I didn’t modify anything in my images. Say, I want to modify something in the Apache, PHP or WordPress configs, I will just put in some shit in the Dockefile like this:
There are so many examples in GitHub 😛
Useful tool to enter a Docker container
docker run –rm -v /usr/local/bin:/target jpetazzo/nsenter
The above snippet downloads and installs https://github.com/jpetazzo/nsenter— a useful tool for you to “enter” a Docker container so that you can edit things like Apache and PHP stuff. An awesome example of its command simplicity is:
docker-enter <Name of WP container>
**Just “fig ps” to know the list of containers.
That’s it! ¯_(ツ)_/¯
Now I am happily developing in my local machine in a Dockerized environment. (saying “Dockerize” is such a poser thing. Sorry! haha)— PS. I did this because my Vagrant was broken. I even risked all my files to upgrade my distro for it to be fixed but it became weird completely I decided to ditch it. I was also probably just brainwashed by a certain Docker fanboy a.k.a. @themarksteve.