Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

benhutchins/docker-mediawiki

Repository files navigation

Deprecrated

This repo is no longer being maintained since it was forked to the official mediawiki docker image, please see:

  1. https://github.com/wikimedia/mediawiki-docker
  2. https://hub.docker.com/_/mediawiki

Repo exists for historic purposes only.

-- Benjamin H.

What is MediaWiki?

MediaWiki is a free and open-source wiki app, used to power wiki websites such as Wikipedia, Wiktionary and Commons, developed by the Wikimedia Foundation and others.

wikipedia.org/wiki/MediaWiki

How to use this image

docker run --name some-mediawiki --link some-mysql:db -v /local/data/path:/data:rw -d benhutchins/mediawiki

Partial explanation of arguments:

  • --link allows you to connect this container with a database container. See Configure Database below for more details.
  • -v is used to mount a shared folder with the container. See Shared Volume below for more details.

Having troubling accessing your MediaWiki server? See Accessing MediaWiki below for help.

Extra configuration options

Use the following environmental variables to generate a LocalSettings.php and perform automatic installation of MediaWiki. If you don't include these, you'll need to go through the installation wizard. See Installation Wizard below for more details. Please see Manual:Configuration_settings for details about what these configuration variables do.

  • -e MEDIAWIKI_SITE_SERVER= (required set this to the server host and include the protocol (and port if necessary) like http://my-wiki:8080; configures $wgServer)
  • -e MEDIAWIKI_SITE_NAME= (defaults to MediaWiki; configures $wgSitename)
  • -e MEDIAWIKI_SITE_LANG= (defaults to en; configures $wgLanguageCode)
  • -e MEDIAWIKI_ADMIN_USER= (defaults to admin; configures default administrator username)
  • -e MEDIAWIKI_ADMIN_PASS= (defaults to rosebud; configures default administrator password)
  • -e MEDIAWIKI_UPDATE=true (defaults to false; run php maintenance/update.php)

As mentioned, this will generate the LocalSettings.php file that is required by MediaWiki. If you mounted a shared volume (see Shared Volume below), the generated LocalSettings.php will be automatically moved to your share volume allowing you to edit it. If a CustomSettings.php file exists in your data file, a require('/data/CustomSettings.php'); will be appended to the generated LocalSettings.php file.

Choosing MediaWiki version

You can use one of the built containers, see all options on Docker Hub.

  • benhutchins/mediawiki:lts (uses 1.27, official Long Term Support by MediaWiki)
  • benhutchins/mediawiki:latest (uses 1.30)
  • benhutchins/mediawiki:1.30
  • benhutchins/mediawiki:1.29
  • benhutchins/mediawiki:1.27
  • benhutchins/mediawiki:1.25
  • benhutchins/mediawiki:1.23

To use one of these pre-built containers, simply specify the tag as part of the docker run command:

docker run --name some-mediawiki --link some-postgres:db -v /local/data/path:/data:rw -d benhutchins/mediawiki:lts

Docker Compose

To run with Docker Compose, you'll need to clone this repository and run:

docker-compose up

Note You'll likely want to uncomment the docker-compose.yml file's volume lines.

Configure Database

The example above uses --link to connect the MediaWiki container with a running mysql container. This is probably not the best idea for use in production, keeping data in docker containers can be dangerous.

Using MySQL

You can use a MySQL database, the recommended database for MediaWiki. Here's an example:

docker run
  -e MEDIAWIKI_DB_TYPE=mysql
  -e MEDIAWIKI_DB_HOST=some-mysql
  -e MEDIAWIKI_DB_USER=mediawiki
  -e MEDIAWIKI_DB_PASSWORD=password
  --name some-mediawiki
  -v /local/data/path:/data:rw
  -d
  benhutchins/mediawiki

Using Postgres

You can also use Postgres instead of MySQL as your database server:

docker run
  -e MEDIAWIKI_DB_TYPE=postgres
  -e MEDIAWIKI_DB_HOST=some-postgres
  -e MEDIAWIKI_DB_USER=mediawiki
  -e MEDIAWIKI_DB_PASSWORD=password
  --name some-mediawiki
  -v /local/data/path:/data:rw
  -d
  benhutchins/mediawiki

Using Database Server

You can use the following environment variables for connecting to another database server:

  • -e MEDIAWIKI_DB_TYPE=... (defaults to mysql, but can also be postgres)
  • -e MEDIAWIKI_DB_HOST=... (defaults to the address of the linked database container)
  • -e MEDIAWIKI_DB_PORT=... (defaults to the port of the linked database container or to the default for specified db type)
  • -e MEDIAWIKI_DB_USER=... (defaults to root or postgres based on db type being mysql, or postgres respsectively)
  • -e MEDIAWIKI_DB_PASSWORD=... (defaults to the password of the linked database container)
  • -e MEDIAWIKI_DB_NAME=... (defaults to mediawiki)
  • -e MEDIAWIKI_DB_SCHEMA... (defaults to mediawiki, applies only to when using postgres)

If the MEDIAWIKI_DB_NAME specified does not already exist on the provided MySQL server, it will be created automatically upon container startup, provided that the MEDIAWIKI_DB_USER specified has the necessary permissions to create it.

To use with an external database server, use MEDIAWIKI_DB_HOST (along with MEDIAWIKI_DB_USER and MEDIAWIKI_DB_PASSWORD if necessary):

docker run --name some-mediawiki \
    -e MEDIAWIKI_DB_HOST=10.0.0.1
    -e MEDIAWIKI_DB_PORT=3306 \
    -e MEDIAWIKI_DB_USER=app \
    -e MEDIAWIKI_DB_PASSWORD=secure \
    benhutchins/mediawiki

Shared Volume

If provided mount a shared volume using the -v argument when running docker run, the mediawiki container will automatically look for a LocalSettings.php file and images, skins and extensions folders. When found symbolic links will be automatically created to the respsective file or folder to replace the ones included with the default MediaWiki install. This allows you to easily configure (LocalSettings.php), backup uploaded files (images), and customize (skins and extensions) your instance of MediaWiki.

It is highly recommend you mount a shared volume so uploaded files and images will be outside of the docker container.

By default the shared volume must be mounted to /data on the container, you can change this using by using -e MEDIAWIKI_SHARED=/new/data/path.

Additionally if a composer.lock and a composer.json are detected, the container will automatically download composer and run composer install. Composer can be used to install additional extensions, skins and dependencies.

Accessing MediaWiki

If you'd like to be able to access the instance from the host without the container's IP, standard port mappings can be used using the -p or -P argument when running docker run. See docs.docker.com for more help.

docker run --name some-mediawiki --link some-mysql:db -p 8080:80 -v /local/data/dir:data:rw -d benhutchins/mediawiki

Then, access it via http://localhost:8080 or http://host-ip:8080 in a browser.

Installation Wizard

The first time you access your new MediaWiki instance, you'll be navigated through an installation wizard. The purpose of which is to setup the default database and to generate a configuration file, LocalSettings.php.

After using the installation wizard, save a copy of the generated LocalSettings.php to your data volume (-v /local/data/dir:/data:rw).

If you're using --link to connect with a database, you'll be requested to specify the database host, user, password and name. Run exec some-mediawiki printenv | grep 'MYSQL\|DB\|POSTGRES' to view the environmental variables relating to the linked database. The database user will not be included, for that use root or postgres depending on whether you're using mysql or postgres respsectively.

Enabling SSL/TLS/HTTPS

To enable SSL on your server, place your certificate files inside your mounted share volume as ssl.key, ssl.crt and ssl.bundle.crt. Then add -e MEDIAWIKI_ENABLE_SSL=true to your docker run command. This will enable the ssl module for Apache and force your instance of mediawiki to SSL-only, redirecting all requests from port 80 (http) to 443 (https). Also be sure to include -P or -p 443:443 in your docker run command.

Consider using an nginx reverse proxy to provide SSL, rather than relying on the container. It will perform better and be easier to manage.

Note When enabling SSL, you must update the $wgServer in your LocalSettings.php to include https:// as the prefix. If using automatic install, update the MEDIAWIKI_SITE_SERVER environmental variable.

Releases

No releases published

Packages

No packages published