How to Deploy MediaWiki Using Docker Compose for Rapid Setup and Management
A fast MediaWiki Docker Compose quickstart for evaluation: official images, one compose file, LocalSettings mount, plus the checklist before going production.
Want to evaluate MediaWiki — or build a small internal wiki — without installing PHP, extensions and a database by hand? Docker Compose gets a wiki running in about ten minutes. This quickstart uses the official images (mediawiki, mariadb), which is fine for evaluation and small deployments; a production-oriented version (backups, upgrades, volume strategy) is covered in the companion article on this blog — that one is the reference once the wiki stops being an experiment.
1. The compose file
services:
mediawiki:
image: mediawiki:lts
restart: unless-stopped
ports:
- "8080:80"
environment:
MEDIAWIKI_DB_HOST: db
MEDIAWIKI_DB_NAME: mediawiki
MEDIAWIKI_DB_USER: mediawiki
MEDIAWIKI_DB_PASSWORD: "${MW_DB_PASSWORD}"
volumes:
- mw-images:/var/www/html/images
- ./LocalSettings.php:/var/www/html/LocalSettings.php:ro
depends_on:
- db
db:
image: mariadb:11
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: "${MW_DB_ROOT_PASSWORD}"
MARIADB_DATABASE: mediawiki
MARIADB_USER: mediawiki
MARIADB_PASSWORD: "${MW_DB_PASSWORD}"
volumes:
- db-data:/var/lib/mysql
volumes:
mw-images:
db-data:
Create a .env next to it with the two passwords, then start the stack:
echo 'MW_DB_PASSWORD=change-me' > .env
echo 'MW_DB_ROOT_PASSWORD=change-me-too' >> .env
docker compose up -d
2. Run the installer
Open http://localhost:8080. The MediaWiki installer asks for database details — use host db, database mediawiki, user mediawiki and the password from .env. Complete the site name and admin account; the installer then offers to download LocalSettings.php. Save it in the project directory and restart:
docker compose up -d # recreates the container with LocalSettings.php mounted
That is a working wiki. Special:Version shows the MediaWiki version and which extensions are bundled.
3. Quick checks and tweaks
- Rebuild after config changes — LocalSettings.php is mounted read-only, so edits apply on
docker compose restart mediawiki; to add an extension during evaluation, mount it like./extensions/Foo:/var/www/html/extensions/Foo:roandwfLoadExtension-load it - Logs —
docker compose logs -f mediawikishows PHP and Apache output for debugging - Test database — wipe everything with
docker compose down -v(volumes included) and you are back to a clean slate — the main advantage of evaluation in containers
4. Before it becomes production
The quickstart is deliberately thin. When this wiki starts holding real content, in order of importance:
- HTTPS — put a reverse proxy (Caddy, Traefik, nginx) in front and terminate TLS; the wiki itself stays on the internal network
- Backups — automate
mariadb-dumpof thedbcontainer and archive themw-imagesvolume - Upgrades — pin the image version (
mediawiki:1.43instead of:lts), and plan themaintenance/run.php updatestep for every bump - Secrets — move
.envout of Git, or use your secret manager (Docker Swarm/Compose secrets, a vault)
Ten minutes to a wiki, one more hour to a production posture. The official mediawiki image documentation and the production-focused companion guide cover the rest.