Docker Documentation
- Docker Documentation
This article provides a comprehensive guide to configuring and running MediaWiki 1.40 within a Docker environment. Utilizing Docker simplifies deployment, ensures consistency, and improves scalability. This tutorial is geared towards newcomers to both Docker and MediaWiki server administration.
== Prerequisites
Before beginning, ensure you have the following installed:
- Docker: The core Docker engine.
- Docker Compose: For simplified multi-container application management.
- Basic familiarity with the command line.
- A basic understanding of MediaWiki installation concepts.
== Docker Image Selection
Multiple Docker images are available for MediaWiki. We recommend using the official image maintained by the MediaWiki community: `docker.io/mediawiki/mediawiki`. This image is regularly updated and includes essential dependencies.
== Docker Compose Configuration
Using Docker Compose simplifies the definition and management of our MediaWiki environment. Create a `docker-compose.yml` file with the following content:
```yaml version: "3.9" services:
mediawiki: image: docker.io/mediawiki/mediawiki:1.40 ports: - "80:80" volumes: - ./config:/var/www/html/config - ./images:/var/www/html/images environment: MW_DB_TYPE: mysql MW_DB_HOST: db MW_DB_NAME: mediawiki MW_DB_USER: root MW_DB_PASSWORD: password depends_on: - db
db: image: mysql:8.0 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: mediawiki
```
This configuration defines two services: `mediawiki` and `db`. The `mediawiki` service uses the official MediaWiki 1.40 image, maps port 80 on the host to port 80 in the container, and mounts local directories for configuration and images. The `db` service uses a MySQL 8.0 image and sets up the necessary environment variables for database access.
== Database Configuration
The `docker-compose.yml` file assumes a MySQL database. The database credentials are defined in the `environment` section. Ensure you modify these for production deployments. You can also use other database types supported by MediaWiki, such as PostgreSQL, by adjusting the `MW_DB_TYPE`, `MW_DB_HOST`, etc., environment variables accordingly.
== Volume Management
The `volumes` section in the `docker-compose.yml` file is crucial for persistent data storage.
- `./config:/var/www/html/config`: This maps a local directory named `config` to the `/var/www/html/config` directory within the container. This is where your `LocalSettings.php` file will reside.
- `./images:/var/www/html/images`: This maps a local directory named `images` to the `/var/www/html/images` directory within the container. This is where uploaded images will be stored.
These volumes ensure that your configuration and uploaded files persist even if the container is stopped or removed.
== Initial Setup & LocalSettings.php
1. Navigate to the directory containing your `docker-compose.yml` file in your terminal. 2. Run `docker-compose up -d` to start the containers. This will download the images (if necessary) and start the MediaWiki and MySQL services in detached mode. 3. Access the MediaWiki installation script in your browser using `http://localhost`. You will be guided through the initial setup process. 4. During the setup process, MediaWiki will prompt you to create a `LocalSettings.php` file. This file contains critical configuration settings. The installer will *attempt* to create it, but we need to adjust permissions and potentially add more configuration.
Create a `LocalSettings.php` file in the `./config` directory (which is mapped to the container's `/var/www/html/config` directory). A minimal `LocalSettings.php` would look like this:
```php <?php require_once("$IP/includes/AutoLoad.php"); $wgEnableSMTP = false; $wgSMTP = array(); $wgSecretKey = 'YOUR_SECRET_KEY'; // Replace with a strong, random key $wgSitename = 'MyMediaWiki'; $wgServer = 'http://localhost';
$wgDBtype = 'mysql'; $wgDBserver = 'db'; $wgDBname = 'mediawiki'; $wgDBuser = 'root'; $wgDBpassword = 'password'; ?> ```
- Important:** Replace `'YOUR_SECRET_KEY'` with a strong, randomly generated string. This key is essential for security.
== Scaling and High Availability
For production environments, consider scaling your MediaWiki deployment using Load Balancing and multiple container instances. Docker Swarm or Kubernetes can be used to manage these deployments.
== Technical Specifications
Below are the recommended technical specifications for a Dockerized MediaWiki 1.40 installation.
Component | Minimum Specification | Recommended Specification |
---|---|---|
CPU | 1 Core | 2+ Cores |
RAM | 2 GB | 4+ GB |
Storage | 20 GB | 50+ GB (SSD Recommended) |
The above specifications are for a small to medium-sized wiki. Larger wikis will require more resources.
== Security Considerations
- **Database Credentials:** Never expose your database credentials in publicly accessible code. Use environment variables as demonstrated in the `docker-compose.yml` file.
- **Secret Key:** Maintain the confidentiality of your `$wgSecretKey`.
- **Regular Updates:** Keep your Docker images and MediaWiki software up to date to address security vulnerabilities.
- **Firewall:** Configure a firewall to restrict access to your MediaWiki server.
- **HTTPS:** Enable HTTPS to encrypt communication between your server and users. See HTTPS Configuration for details.
== Troubleshooting
| Problem | Possible Solution | |---|---| | Installation script not accessible | Verify Docker containers are running (`docker-compose ps`). Check firewall rules. | | Database connection errors | Verify database credentials in `LocalSettings.php` and `docker-compose.yml`. Ensure the database server is running. | | Slow performance | Increase CPU and RAM allocated to the containers. Use SSD storage. Optimize database queries. |
== Further Resources
- MediaWiki Official Documentation
- Docker Documentation
- Docker Compose Documentation
- MySQL Documentation
- PHP Configuration
Intel-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Core i7-6700K/7700 Server | 64 GB DDR4, NVMe SSD 2 x 512 GB | CPU Benchmark: 8046 |
Core i7-8700 Server | 64 GB DDR4, NVMe SSD 2x1 TB | CPU Benchmark: 13124 |
Core i9-9900K Server | 128 GB DDR4, NVMe SSD 2 x 1 TB | CPU Benchmark: 49969 |
Core i9-13900 Server (64GB) | 64 GB RAM, 2x2 TB NVMe SSD | |
Core i9-13900 Server (128GB) | 128 GB RAM, 2x2 TB NVMe SSD | |
Core i5-13500 Server (64GB) | 64 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Server (128GB) | 128 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Workstation | 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000 |
AMD-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Ryzen 5 3600 Server | 64 GB RAM, 2x480 GB NVMe | CPU Benchmark: 17849 |
Ryzen 7 7700 Server | 64 GB DDR5 RAM, 2x1 TB NVMe | CPU Benchmark: 35224 |
Ryzen 9 5950X Server | 128 GB RAM, 2x4 TB NVMe | CPU Benchmark: 46045 |
Ryzen 9 7950X Server | 128 GB DDR5 ECC, 2x2 TB NVMe | CPU Benchmark: 63561 |
EPYC 7502P Server (128GB/1TB) | 128 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/2TB) | 128 GB RAM, 2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/4TB) | 128 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/1TB) | 256 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/4TB) | 256 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 9454P Server | 256 GB RAM, 2x2 TB NVMe |
Order Your Dedicated Server
Configure and order your ideal server configuration
Need Assistance?
- Telegram: @powervps Servers at a discounted price
⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️