Setting up MediaWiki using Docker Compose and Mariadb: Difference between revisions

From JohnHobson.ws
Jump to navigation Jump to search
No edit summary
No edit summary
Line 10: Line 10:
'''2''' - Inside this folder we need to create a file named docker-compse.yml and copy the following into it
'''2''' - Inside this folder we need to create a file named docker-compse.yml and copy the following into it


<code>version: '3'</code>
<pre>
# MediaWiki with MariaDB
#
# Access via "http://localhost:8080"
#  (or "http://$(docker-machine ip):8080" if using docker-machine)
version: '3'
services:
  mediawiki:
    image: mediawiki
    restart: always
    ports:
      - 4820:80
    links:
      - database
    volumes:
      - /home/john/docker/testwiki/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
      #- /home/john/docker/testwiki/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
    restart: always
    ports:
      - 4840:3306
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: testwikidb
      MYSQL_USER: testwikiuser
      MYSQL_PASSWORD: testwikipassword
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
    volumes:
      - /home/john/docker/testwikidb/db:/var/lib/mysql


<code>services:</code>
volumes:
 
  images:
<code>  mediawiki:</code>
  db:
 
</pre>
<code>    image: mediawiki</code>
 
<code>    restart: always</code>
 
<code>    ports:</code>
 
<code>      - 4820:80</code>
 
<code>    links:</code>
 
<code>      - database</code>
 
<code>    volumes:</code>
 
<code>      - /home/john/docker/testwiki/images:/var/www/html/images</code>
 
<code>      # After initial setup, download LocalSettings.php to the same directory as</code>
 
<code>      # this yaml and uncomment the following line and use compose to restart</code>
 
<code>      # the mediawiki service</code>
 
<code>      #- /home/john/docker/testwiki/LocalSettings.php:/var/www/html/LocalSettings.php</code>
 
<code>  # This key also defines the name of the database host used during setup instead of the default "localhost"</code>
 
<code>  database:</code>
 
<code>    image: mariadb</code>
 
<code>    restart: always</code>
 
<code>    ports:</code>
 
<code>      - 4840:3306</code>
 
<code>    environment:</code>
 
<code>      # @see <nowiki>https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php</nowiki></code>
 
<code>      MYSQL_DATABASE: testwikidb</code>
 
<code>      MYSQL_USER: testwikiuser</code>
 
<code>      MYSQL_PASSWORD: testwikipassword</code>
 
<code>      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'</code>
 
<code>    volumes:</code>
 
<code>      - /home/john/docker/testwikidb/db:/var/lib/mysql</code>
 
<code>volumes:</code>
 
<code>  images:</code>
 
<code>  db:</code>

Revision as of 03:34, 23 November 2024

Back to Homepage

WORK IN PROGRESS NOT FINISHED YET

PREFACE - I am going to assume that you already have a server/PC with Linux installed. You will also need Docker and Docker-Compose installed

I found it a little hard to setup MediaWiki for the first time using Docker and getting all the database working correctly. I have now run a few instances of it and decided to write a short post on getting it working

1 - First we need to create our directory. For this test we will be using /home/john/docker/testwiki

2 - Inside this folder we need to create a file named docker-compse.yml and copy the following into it

# MediaWiki with MariaDB
#
# Access via "http://localhost:8080"
#   (or "http://$(docker-machine ip):8080" if using docker-machine)
version: '3'
services:
  mediawiki:
    image: mediawiki
    restart: always
    ports:
      - 4820:80
    links:
      - database
    volumes:
      - /home/john/docker/testwiki/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
      #- /home/john/docker/testwiki/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
    restart: always
    ports:
      - 4840:3306
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: testwikidb
      MYSQL_USER: testwikiuser
      MYSQL_PASSWORD: testwikipassword
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
    volumes:
      - /home/john/docker/testwikidb/db:/var/lib/mysql

volumes:
  images:
  db: