Quick Wordpress Install with Docker
I’ve just put together a Wordpress site for my older daughter. It’s hosted on DigitalOcean and all of the infrastructure is handled with Docker. This post describes the steps in the (easy) install process.
The first thing that you need to do is install Docker. With that in place it’s a simple matter to instantiate a couple of images and the whole thing is up an running.
MySQL Docker Container
Wordpress stores content in a MySQL database. Since we want to persist that data beyond the lifespan of a Docker container we should store the data on the host. First create a folder for the database data.
Next create a (temporary) environment variable to store the MySQL
root user password. This is not really necessary, but it made my life easier.
Now launch an instance of the MySQL Docker image. Note that the folder created above is listed as a volume and linked to the folder
/var/lib/mysql on the container.
Check that the container is up and running.
We see that it’s listening on the (default) port 3306.
Wordpress Docker Container
Wordpress also stores content (templates, media etc.) in a folder. Again we want to persist this on the host, so we create a folder for the Wordpress content.
Then launch the Wordpress Docker image. The folder created above is listed as a volume and linked to the folder
/var/www/html/wp-content on the container. This container is also linked to the
Again we check that the container is up and running.
Looks good. At this point we can do a local test on the host. Since the site is not yet visible from the outside world we’ll use
lynx to open it.
If you get something that looks like a (text mode) web page then you are in business.
Finally we need to expose the site to the outside world. I don’t pretend to be particularly competent with NGINX, but the configuration below worked for me, exposing the site on port 80.
Restart NGINX and the site will be live.
I was so enthused by the ease of the above process (thank you, Docker!) that I decided to install a blog on another web site. In this case the main site is served on HTTPS. I didn’t have the time to sort out SSL for the blog, so instead I put it on a separate sub-domain. All that was required was an extra entry in the NGINX
I’m once again astonished and thrilled by the ease with which things can be accomplished with Docker. Without it this install would probably have taken a couple of hours. However, I managed to research and implement all of this in less than an hour. And that’s a reflection on the tool, not on me!