Skip to content

epuzanov/mediawiki-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 wiki -p 80:80 -e MEDIAWIKI_SITE_SERVER=http://wiki.example.com -d epuzanov/mediawiki

Partial explanation of arguments:

  • --net 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.

  • -e MEDIAWIKI_SITE_SERVER= (required set this to the server host and include the protocol (and port if necessary) like //wiki; 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 Pa55word+; configures default administrator password)
  • -e MEDIAWIKI_UPDATE=true (defaults to false; run php maintenance/update.php)
  • -e MEDIAWIKI_DB_TYPE= (defaults to sqlite; configures $wgDBtype)
  • -e MEDIAWIKI_DB_HOST= (defaults to db; configures $wgDBserver)
  • -e MEDIAWIKI_DB_PORT= (defaults to 3306; configures $wgDBport)
  • -e MEDIAWIKI_DB_SCHEMA= (defaults to mediawiki; configures $wgDBmwschema)
  • -e MEDIAWIKI_DB_USER= (defaults to wikiuser; configures $wgDBuser)
  • -e MEDIAWIKI_DB_PASS= (defaults to autogenerated; configures $wgDBpassword)
  • -e MEDIAWIKI_DB_INSTALL_USER= (defaults depends on MEDIAWIKI_DB_TYPE)
  • -e MEDIAWIKI_DB_INSTALL_PASS= (defaults depends on MEDIAWIKI_DB_TYPE)
  • -e MEDIAWIKI_DB_NAME= (defaults to wikidb; configures $wgDBname)
  • -e MEDIAWIKI_SCRIPTPATH= (defaults to ``; configures $wgScriptPath)
  • -e MEDIAWIKI_MEMCACHED= (defaults to ``; configures $wgMemCachedServers)
  • -e MEDIAWIKI_LDAP_SERVERS= (defaults to dc.example.com; configures $wgLDAPServerNames)
  • -e MEDIAWIKI_LDAP_AGENT= (defaults to cn=proxyagent,ou=Users,dc=example,dc=com; configures $wgLDAPProxyAgent)
  • -e MEDIAWIKI_LDAP_AGENT_PASS= (defaults to password; configures $wgLDAPProxyAgentPassword)
  • -e MEDIAWIKI_LDAP_BASEDN= (defaults to dc=example,dc=com; configures $wgLDAPBaseDNs)

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.

Choosing MediaWiki version

We currently track latest MediaWiki production branches, as run on wikipedia.org.

  • epuzanov/mediawiki:latest (currently uses REL1_30)

Configure Database

The example above uses --net or --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. Supported Databases:

  • MySQL (MEDIAWIKI_DB_TYPE=mysql)
  • Postgres (MEDIAWIKI_DB_TYPE=postgres)
  • SQLite (MEDIAWIKI_DB_TYPE=sqlite)
  • MS SQL (MEDIAWIKI_DB_TYPE=mssql)

Using SQLite

You can use SQLite backand for small MediaWiki setup without dedicated Database Server. MediaWiki SQLite database files will be saved in wiki configuration Shared Volume.

docker run --name wiki -p 80:80 -v /local/wiki_data/path:/data:rw -e MEDIAWIKI_SITE_SERVER=http://wiki.example.com -d epuzanov/mediawiki

Using MySQL

You can use MySQL as your database server:

docker run --name wiki --link some-mysql:db -p 80:80 -v /local/wiki_data/path:/data:rw -e MEDIAWIKI_DB_TYPE=mysql -e MEDIAWIKI_DB_INSTALL_PASSWORD=Pa$$w0rd -e MEDIAWIKI_SITE_SERVER=http://wiki.example.com -d epuzanov/mediawiki

Using Postgres

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

docker run --name wiki --link some-postgres:db -p 80:80 -v /local/wiki_data/path:/data:rw -e MEDIAWIKI_DB_TYPE=postgres -e MEDIAWIKI_DB_INSTALL_PASSWORD=Pa$$w0rd -e MEDIAWIKI_SITE_SERVER=http://wiki.example.com -d epuzanov/mediawiki

Using Database Server

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

  • -e MEDIAWIKI_DB_TYPE=... (defaults to sqlite, but can also be mysql, postgres or mssql)
  • -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, sa or postgres based on db type being mysql, mssql 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)
  • -e MEDIAWIKI_DB_INSTALL_USER=... (defaults to root, sa or postgres based on db type being mysql, mssql or postgres respsectively)
  • -e MEDIAWIKI_DB_INSTALL_PASSWORD=... (defaults to the password of the linked database container)

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_INSTALL_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 wiki -e MEDIAWIKI_DB_HOST=10.0.0.1 -e MEDIAWIKI_DB_PORT=3306 -e MEDIAWIKI_DB_USER=wikiuser -e MEDIAWIKI_DB_PASSWORD=password epuzanov/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, Images directory, SSL certificats and wiki.png logo file. This allows you to easily configure (LocalSettings.php), update SSL certificats and MediaWiki Logo. 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.

Using SSL

Replace server.key and server.crt files on shared volume with you files. docker run --name wiki -p 443:443 -e MEDIAWIKI_SITE_SERVER=https://wiki.example.com -d epuzanov/mediawiki

Multiple Wikis with mediawiki-fpm

docker run --name wiki1 --net wikinet -v /local/wiki1:/data:rw -e MEDIAWIKI_SITE_SERVER=http://wiki1.example.com -d epuzanov/mediawiki /usr/sbin/php-fpm
docker run --name wiki2 --net wikinet -v /local/wiki2:/data:rw -e MEDIAWIKI_SITE_SERVER=http://wiki2.example.com -d epuzanov/mediawiki /usr/sbin/php-fpm
docker run --name wiki3 --net wikinet -v /local/wiki3:/data:rw -e MEDIAWIKI_SITE_SERVER=http://wiki3.example.com -d epuzanov/mediawiki /usr/sbin/php-fpm
docker run --name httpd --net wikinet -p 80:80 -v /local/wiki1:/data/wiki1:rw -v /local/wiki2:/data/wiki2:rw -v /local/wiki3:/data/wiki3:rw -d epuzanov/mediawiki