Raspberry Pi WordPress Blog with Docker

Ever wanted to quickly get a wordpress blog up and running on your Raspberry Pi? Well here’s how you can do it!

Prerequisite:

Raspberry Pi – https://amzn.to/36i6T5P*Amazon Affiliate Link*

This assumes you have a raspberry pi with Raspbian installed.

Install docker and docker compose

sudo apt-get install docker.io docker-compose

create a place for the blog to live

mkdir blog
cd blog

Create the following 3 files using your favourite text editor

docker-compose.yml

version: '3'
services:
    wordpress:
        container_name: wordpress
        image: wordpress
        volumes:
            - '/home/pi/blog/html:/var/www/html'
        ports:
            - '80:80'
        env_file:
            - blog_env
    mysql:
        container_name: mysql
        image: hypriot/rpi-mysql
        volumes:
            - '/home/pi/blog/data:/var/lib/mysql'
        env_file:
            - mysql_env
    redis:
        image: redis
        container_name: redis
volumes:
    mysql: null
    wordpress: null

mysql_env

MYSQL_ROOT_PASSWORD=secret
MYSQL_DATABASE=blog
MYSQL_USER=blog_user
MYSQL_PASSWORD=blogSecret

blog_env

WORDPRESS_DB_HOST=mysql
WORDPRESS_DB_USER=blog_user
WORDPRESS_DB_PASSWORD=blogSecret
WORDPRESS_DB_NAME=blog

Finally, run the following command to launch the blog:

sudo docker-compose up -d --build