WordPress on Docker: The 1-2-3 approach

There’s an official WordPress docker image on the hub. Which means I have no good excuse to go make my own. Here’s my bad excuse: The official approach contains Apache and WordPress files all mashed up in one image. This feels icky to me partly because I don’t know Apache, having decided early on to hitch my wagon to Nginx, partly because it feels un-containerly to have everything in one big pot.

I cannot argue the merits and demerits of the official image with regards to performance, scalability, or security. What I saw was an opportunity to solve the problem in a way that felt more correct to me – 1 network, 2 volumes, 3 containers,  – that would also work as a learning experience. Here’s how I did it.


Playing fast(cgi) and loose

Problem: On all my non-https enabled WordPress sites, the links to CSS and images were always https which meant they failed, rendering as pure html. Assumption: It’s either a WordPress or an nginx issue. Solution: Turns it it was neither but a bad fastcgi parameter. Lesson: Kids, don’t copy-paste fastcgi parameters.