EZ Wordpress instance with docker compose

Setting up an instance of Wordpress easily with Docker Compose

This post is one I wrote a while back but never published, as I’ve found some free time now, I’m going through and putting together posts that I jotted down but never got to publishing.

tldr; Wordpress in a container, full docker compose file is @ the bottom

Wordpress is one of (if not the) best open source Content Management Systems (CMS) out there. As any software that has been fortunate to grow old/expected with wide use, Wordpress certainly has it’s warts, but it is by far and away the most popular choice for a platform that is easy for users to setup, get started with, and manage. To top it all off, it’s open source and has one of thet few rare working large-scale monetization models available to Open Source Software (OSS) today.

Recently while building a project for a client, we needed to almost completely overhaul their existing wordpress site (some bad viruses had infected their host, and the old site wasn’t really needed. During the early stages of this project I wanted to get wordpress running locally on my own servers so others I was working with (and the client) could easily view the progress and suggest changes to the site as it was being developed. A longtime (if you can even count a few years as a “long time”) fan of Docker and the benefits of containerization, surely it would be easy to:

  • Get a decent quality docker image for wordpress

  • Set up NGINX with php-fpm to serve the PHP that makes Wordpress tick

  • Reverse proxy (with NGINX) to the docker container running wordpress (w/ SSL stopping @ NGINX)

Luckily, inline with my expectations all this was actually super easy to do. While I didn’t quite completely configure Wordpress (or docker for that matter) for longevity, it was relatively easy to get a simple page up. Also, it was super easy to use docker for local dev of the wordpress environment.

Docker Compose file:

Without further ado, here’s the docker compose file:

version: '2'
     image: wordpress
       - ./wp-config.ini:/usr/local/etc/php/conf.d/uploads.ini
       - wp-db:mysql
       MYSQL_PORT_3306_TCP: 'mysql'
       WORDPRESS_DB_PASSWORD: 'example'
       - 8080:80
         - wp-db

     image: mariadb
       - "3306"
       MYSQL_ROOT_PASSWORD: example

I used the official wordpress image, as well as the official mariadb image. Note that this configuration does NOT account for persistence - you’d need to mount a volume into the wp-db component for that, and while I’m about to go through the experience (I have some some more WP projects coming up), I haven’t quite yet, so you’ll need to figure that part out yourself. Once I get to working on my next wordpress project I’ll circle back and update this post.. hopefully.