Mastodon Icon RSS Icon GitHub Icon LinkedIn Icon RSS Icon

How to install MediaWiki on Docker

A quick 10-steps installation guide

A personal wiki is something that attracts me like a moth to a flame. It always did since I started contributing to Wikipedia 19 years ago (wow). Nowadays, for my day to day use, I use Obsidian like a normal human beings (you can replace Obsidian with any note-taking application; they all have backlinks now).

Still, there are some use case that may require a more traditional wiki. For instance, making a wiki for my home, with useful information about my house (maintenance, “how to”, etc.) that my family can access on my LAN. Or a wiki that needs to be edited by multiple people. Or something that looks more “official” (e.g., for a wiki for my world-building). These scenarios, MediaWiki, the platform that powers the entire Wikipedia, may be a valid alternative.

Even in these cases, though, using MediaWiki may be an overkill. It is like using an entire 4th generation nuclear power plant only to charge your phone. There are much simpler solutions out there. However, if you are here, you are like me: you like having fun with overtly complex software and, most importantly, you like to have the most powerful tool in hand.

Luckily, installing MediaWiki is not that hard. Especially if you already use Docker for other things. So, here it is a quick and easy way to have a MediaWiki instance running locally in 10 minutes.

Step by Step Guide

  1. Create an empty folder (e.g., mywiki).
  2. In that folder, let’s create a docker-compose.yml file with the following content:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
services:

  mediawiki:
    image: mediawiki:latest
    container_name: mediawiki
    ports:
      - "8080:80"
    environment:
      MEDIAWIKI_DB_HOST: db
      MEDIAWIKI_DB_USER: mediawiki
      MEDIAWIKI_DB_PASSWORD: <db_pasword>
      MEDIAWIKI_DB_NAME: mediawiki
    depends_on:
      - db
    volumes:
      - ./mediawiki_data:/var/www/html/images
      # - ./LocalSettings.php:/var/www/html/LocalSettings.php

  db:
    platform: linux/x86_64
    image: mysql:5.7
    ports:
      - "3306:3306"
    container_name: mediawiki_db
    environment:
      MYSQL_ROOT_PASSWORD: <db_root_passord>
      MYSQL_DATABASE: mediawiki
      MYSQL_USER: mediawiki
      MYSQL_PASSWORD: <db_password>
    volumes:
      - ./db_data:/var/lib/mysql
  1. There are a couple of things to note:
    1. There is a commented line in volumes. This needs to be un-commented in Step 8. I’ll explain then.
    2. On a mac with an M1 chip, mysql:5.7 will fail the installation (there is no ARM-compatible binary for that particular MySQL version). No worries. You can set platform: linux/x86_64 to force the AMD64 version. As an alternative, I think you can use a MariaDB image, but I didn’t test it. If you don’t plan to have so many concurrent edits that the performance hit will be noticeable, I think you can stick with my solution.
  2. Replace <db_password> and <db_root_password> with a secure password. We are using 2 database users: a root user for the installation, and a mediawiki user for the normal operation. If you plan to use the wiki only locally, you could just use the root user. However, once again, I didn’t test that.
  3. Run the containers with docker compose up -d. This will pull the images and run the service. When ready, go to localhost:8080 and follow the standard MediaWiki installation procedure.
  4. After that, MediaWiki will tell you to download a configured LocalSettings.php file.
  5. Copy this file in the folder with docker-compose.yml. At this point, you should have a folder with two files (docker-compose.yml and LocalSettings.php) and two folders (db_data and mediawiki_data).
  6. Now it is time to un-comment the line - ./LocalSettings.php:/var/www/html/LocalSettings.php from docker-compose.yml.
  7. Shutdown the container (docker compose down) and bring it back up (docker compose up -d).
  8. Go once again to localhost:8080 and you should be able to see your wiki. Log in with the user you created during the installation and you are ready to go.

Troubleshooting

I got no problems with this, but I am experienced enough to know that errors are always ready to ambush us.

Therefore, I’ll update this section with the answers to the errors you may encounter. Ping me on Mastodon or Bluesky.

Next Steps

Now that you have a running installation, you can start filling it. And, most importantly, customize it. Starting, of course, with changing the wiki’s logo.

If you want to back up your wiki, just copy the folder somewhere (in our example mywiki). It is all you need.

I hope this is useful. :) Bye.