A Dockered Mediawiki on DietPi Raspberry Pi

Messed around with this really late last night. Essentially I have a Raspberry Pi 3B+ that runs the DietPi distro (which is basically Raspbian Lite, but much more lightweight and bare bones).

First I had to install docker on the DietPi, thankfully DietPi comes with a software utility, but it wouldn't have been required as installing Docker is pretty simple through the command line. If you want to install Docker on your raspberry-pi and don't want to use a GUI-based tool just use these commands one at a time either as root to not have to type sudo each time it says (sudo -s and your default user's password) or just use each line here, one at a time:

This should run Docker's hello-world container and give you an output similar to this:

$ docker container run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1eda109e4da: Pull complete
Digest: sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm32v7)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/

That should show you that Docker is installed and working. If not work your way through these steps again to make sure you got it right. Or use the software package installer on whatever distro you are using, in case they have a way of easily installing Docker.

Now, for Mediawiki on Docker, remember you have to make sure anything you run from Docker on the raspberry Pi is an ARM/ARM64 compatible container. If not, it just won't run. Search for the "mediawiki" container on https://hub.docker.com/

Follow their instructions like so, I personally used a non-standard port since I run pi-hole on port 80:

$ docker run --name mediawiki -p 8080:80 -d mediawiki

Then just head on over to http://host-ip:8080/ and follow the config instructions. If you don't run the -p 8080:80 tag, it will just be http://host-ip/ and that's it. You can change the bit after --name to whatever you want to call the container. Remember, you shouldn't have two containers with the same name, since it would be very hard to manage them. Keep that in mind moving forward with your docker learning. You will need to copy the LocalSettings.php file you download in the browser, into the mediawiki container. Before proceeding below, try and figure that out yourself! Could be fun. I go into docker container copying below though.

Proceed only after you have completed configuration and transferred your LocalSettingsPHP to /var/www/html/ - If you don't you might have to go back and do a few things again!

An interesting side note. I wanted to use my own logo for the mediawiki and had to learn how to do it all. I had previous mounted my network share for my FreeNAS server's folder location of /mnt/v1/media as /mnt/share on the pi to use as a schedule copy location for the local rsync'd backup of the pi.

I decided to use this /mnt/share location as the area I would transfer the image from my Windows desktop, or anything I wish to send to the pi. This is so I can avoid having to run SAMBA/FTP/etc... on my pi. The less services as possible the better, in my view. I don't need my pi to run file sharing servers, since it can access mounted network shares from my NAS directly that are shared with all my devices on my intranet!

So I had to learn how to copy that image from that shared folder into the new mediawiki docker container. I didn't even know if you could do it this easily but...

Then you have to modify the php file for the local settings, /var/www/html/LocalSettings.phpto change the logo. This will require entering the docker container with bash, installing a text editor, and editing the file's configuration. I'm sure there's an easier way, but I thought it would be fun to install nano (my preferred editor in linux as it's super simple and comes default on most *nix-style distros so everyone should know how to use it) into this docker container. First we need to get into the docker container's terminal, like so:

$ docker exec -it mediawiki /bin/bash

You should see the terminal prompt change to:

root@d3e73d41bf4d:/var/www/html#

That means you're in :P. Now, time to edit that file, but we have to install nano first as this docker container doesn't have it. I'm sure there is an exec string that can do this a bit easier, but why not show you how to install nano if your linux distro doesn't even have it?

$ apt-get update
$ apt-get install nano

Then you should have nano, time to edit that text!

$ nano /var/www/html/LocalSettings.php

Find the variable $wgLogo and change it:

$wgLogo = "/var/www/html/resources/assets/logo.jpg"

Save the file with ctrl+o, use ctrl+x to exit nano, and test the wiki.

And our end result is this:

So looks like we installed docker on DietPi on our RaspberryPi, and we ran media wiki within a docker container, configured MediaWiki, and gave it a custom logo! See? That wasn't too hard!