简体   繁体   中英

How to setup MediaWiki as a docker container

I cannot seem to understand how to setup MediaWiki in a docker container.

  1. Based on the MediaWiki documentation, I have prepared a yaml file as follows:
version: '3'
services:
  mediawiki:
    image: mediawiki
    restart: always
    ports:
      - 8080:80
    links:
      - database
    volumes:
      - images:/var/www/html/images
      # After initial setup, download LocalSettings.php to the same directory as
      # this yaml and uncomment the following line and use compose to restart
      # the mediawiki service
      # - ./LocalSettings.php:/var/www/html/LocalSettings.php
  # This key also defines the name of the database host used during setup instead of the default "localhost"
  database:
    #image: mariadb
    image: mysql
    restart: always
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: my_wiki
      MYSQL_USER: wikiuser
      MYSQL_PASSWORD: example
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
    volumes:
      - db:/var/lib/mysql

volumes:
  images:
  db:
  1. I then start the containers using docker-compose -f mediawiki.yml up and the mediawiki and database container are up

  2. When accessing the url localhost:8080 , I see

MediaWiki 1.38.2
LocalSettings.php not found.
Please complete the installation and download LocalSettings.php.

I now perform the configuration with the following database parameter:

Database type: MariaDB, MySQL, or compatible
Database host: database
Database name (no hyphens): my_wiki
Database table prefix (no hyphens):
Database username: wikiuser
Database password: example
  1. After the configuration is complete I see the following error message and am stuck:
Setting up database...
[64989d89dafa96653c6354f1] /mw-config/index.php?page=Install Wikimedia\Rdbms\DBQueryError: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading or after adding a new extension?

Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Upgrading and https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:How_to_debug for more information.

Error 1044: Access denied for user 'wikiuser'@'%' to database 'my_wiki' (database)
Function: MysqlInstaller::setupDatabase
Query: CREATE DATABASE `my_wiki`CHARACTER SET utf8
Backtrace:

from /var/www/html/includes/libs/rdbms/database/Database.php(1606)
#0 /var/www/html/includes/libs/rdbms/database/Database.php(1590): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /var/www/html/includes/libs/rdbms/database/Database.php(1564): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /var/www/html/includes/libs/rdbms/database/Database.php(1173): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /var/www/html/includes/installer/MysqlInstaller.php(450): Wikimedia\Rdbms\Database->query(string, string)
#4 /var/www/html/includes/installer/Installer.php(1680): MysqlInstaller->setupDatabase(MysqlInstaller)
#5 /var/www/html/includes/installer/WebInstallerInstall.php(44): Installer->performInstallation(array, array)
#6 /var/www/html/includes/installer/WebInstaller.php(270): WebInstallerInstall->execute()
#7 /var/www/html/mw-config/index.php(82): WebInstaller->execute(array)
#8 /var/www/html/mw-config/index.php(40): wfInstallerMain()
#9 {main}

What am I missing here?

Not a docker expert but have you done the setup shown the middle of your Yamal file under images?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM