#1 Installing WordPress on a Raspberry Pi with docker-compose in under 10 minutes

Jumping to the meat and potato a short set of instructions are presented on how you can have a WordPress instance up and running in under 10 minutes on your Raspberry Pi.

Preperation / Prerequisite

To start off: what you want is a domain name. Since you will be hosting your Raspberry Pi from home and most likely will not have a static IP you also need to tell your domain provider about your changing IP. Luckily no-IP provides both a DDNS service and free domain names. My router also had an option to inform no-IP about my changing IP.

Also don’t forget to forward the ports 80 and 443 which will be incoming traffic to your website. If you are going bigger and get your own domain name you could configure Cloudflare as your nameserver. By establishing a CNAME link to your free domain name at no-IP your new domain name will automatically resolve to the dynamic IP address. An advantage using Cloudflare is, that as a content delivery network, it can cache your website. Additionally it also provides TLS certificates.

Now i assume you already managed all this and have your Raspberry with an installed OS, mine is Raspbian, ready to go .

Lets get started

First we need to install docker on our Raspberry Pi:

curl -sSL https://get.docker.com | sh

Now we want to install docker-compose. It helps us to run multiple containers with one configuration file.

sudo apt-get install docker-compose

We can now procceed to clone my repository

git clone https://gitlab.com/nm_hung93/dockerized-wordpress-on-raspberry-pi.git

For this setup i am using:

We could now configure the mount points of our docker-compose.yml. Per default they will be created in the same folder in which we cloned the repository.

It is possible to create a database when initiating the MariaDB container. This can be done through injected environment variables which we specify in /data/env_variables/env_file.

Now being still in the root folder we can download WordPress:

curl -sL http://wordpress.org/latest.tar.gz | tar --strip 1 -xz -C data/wp/www

Navigate to our WordPress installation folder and copy the wp-config-sample.php and edit it. If you are still in your root folder it should look like this:

cd data/wp/www/
cp wp-config-sample.php wp-config.php
nano wp-config.php
inside the wp-config.php file should be a line which looks like in this picture

Change the settings accordingly to our initiated database:

    • ‘database_name_here’ into blog
    • ‘username_here’ into UserX
    • ‘password_here’ into 123456
    • ‘localhost’ into mariadb

Save the file with CTRL+X and accept saving the file with Y.

Now we are all set. Navigate into our root folder and run docker-compose with

 docker-compose -f docker-compose.yml up -d
    • -f specifies the file
    • -d means detached meaning it runs in the background

The Console should look like this:

Now find the IP address of your Raspberry Pi for example with:

ip addr show

And look out for eth0 or wlan0 depending on your used network interface. Mine is We can now go to another machine inside our network and insert this IP address into our browser.

SUCCESS we did it

Now the next steps you could do are :

  • mount the folders to another directory
  • edit the Caddyfile such as commenting tls off, and replacing :80 with yourwebsite.com to actually serve your website
  • edit the /data/env_variables/mysql_credentials file to have more customized database credentials

<<< Previous: #0 Introduction to Docker and WordPress

>>> #2 Containerized WordPress: General troubleshooting and Migration

2 Replies to “#1 Installing WordPress on a Raspberry Pi with docker-compose in under 10 minutes”

Leave a Reply

Your email address will not be published.