Deploying WordPress Using nix-docker

Yesterday I wrote about nix-docker, a way to use Nix to provision Docker images in a nice way. Today I spent a little bit of time on a sample nix-docker configuration to deploy WordPress to a Docker container to demonstrate that nix-docker is not just a toy, but can be used to deploy a “real” complex-ish system implementing best practices like storing all state (mysql data, uploads, logs) that needs to persist between container restarts in a volume.

The result can be found here. It’s ~130 lines long, but quite a bit of that is comments. It implements the following:

  • MySQL storing its data in the Docker volume /data under /data/mysql
  • Apache with PHP5 enabled listening on exposed port 80 and storing logs in /data/log
  • WordPress with an extra theme (to show how to do that), configured to store uploads in /data/uploads so that they, too, survive container restarts.

That’s it!

The result is a container that stores all important data in a volume, which you can mount from the host machine for easy back-up. To use:

# nix-docker -b -t wordpress-app wordpress.nix
# mkdir -p /data
# docker run -v /data:/data -p 80:80 -t -i wordpress-app

And voila!

wordpress screenshot

Got something to say?
  1. ZK says:

    Hi Zef,

    Slight off-topic – Do you mind if I send you my CV by email? I’m interested in employment at LogicBlox.

    Thank you.

  2. Zef Hemel says:

    Go ahead (zef.hemel@logicblox.com)

Trackbacks for this post

  1. Declaratively Provision Docker Images Using Nix - Zef.me

Comments are closed now.