Docker Tutorial
- Docker Tutorial
This tutorial provides a comprehensive guide to setting up a MediaWiki installation using Docker and Docker Compose. This method offers a consistent and isolated environment, simplifying deployment and management. It is intended for users with some familiarity with the command line and basic server administration concepts.
== Prerequisites
Before you begin, ensure you have the following installed on your server:
- Docker engine (version 20.10.0 or higher recommended)
- Docker Compose (version 1.29.2 or higher recommended)
- A basic understanding of Linux command-line operations.
- Sufficient system resources (see the "Resource Requirements" section below).
== Resource Requirements
The following table outlines the recommended minimum resource requirements for running MediaWiki in Docker:
Resource | Minimum Requirement | Recommended |
---|---|---|
CPU | 1 Core | 2+ Cores |
Memory (RAM) | 2 GB | 4+ GB |
Disk Space | 20 GB | 50+ GB (depending on wiki size) |
Operating System | Linux (Ubuntu, Debian, CentOS recommended) | Linux (Ubuntu, Debian, CentOS recommended) |
These are estimates and may vary depending on the size and activity of your wiki.
== Docker Compose File
The core of this setup is the `docker-compose.yml` file. This file defines the services required for MediaWiki – typically a MariaDB database and an Apache web server running PHP.
Here's a sample `docker-compose.yml` file:
```yaml version: "3.9"
services:
db: image: mariadb:10.6 container_name: mediawiki_db restart: always environment: MYSQL_ROOT_PASSWORD: your_root_password MYSQL_DATABASE: mediawiki MYSQL_USER: mediawiki MYSQL_PASSWORD: your_mediawiki_password volumes: - db_data:/var/lib/mysql
web: image: mediawiki:latest container_name: mediawiki_web restart: always ports: - "80:80" depends_on: - db environment: MW_DB_TYPE: mariadb MW_DB_SERVER: db MW_DB_NAME: mediawiki MW_DB_USER: mediawiki MW_DB_PASSWORD: your_mediawiki_password volumes: - wiki_data:/var/www/html
volumes:
db_data: wiki_data:
```
- Important:** Replace `your_root_password` and `your_mediawiki_password` with strong, secure passwords.
== Explanation of the Docker Compose File
Let's break down the `docker-compose.yml` file:
- `version: "3.9"`: Specifies the Docker Compose file version.
- `services:`: Defines the services that will be run.
* `db:`: Defines the MariaDB database service. * `image: mariadb:10.6`: Uses the official MariaDB 10.6 image from Docker Hub. * `container_name: mediawiki_db`: Assigns a name to the container. * `restart: always`: Ensures the container restarts automatically if it fails. * `environment:`: Sets environment variables for the database. * `volumes:`: Mounts a volume to persist the database data. This is crucial so your data isn't lost when the container is stopped or removed. * `web:`: Defines the MediaWiki web server service. * `image: mediawiki:latest`: Uses the official MediaWiki image from Docker Hub. `latest` pulls the most recent version. * `container_name: mediawiki_web`: Assigns a name to the container. * `restart: always`: Ensures the container restarts automatically if it fails. * `ports:`: Maps port 80 on the host machine to port 80 inside the container. This allows you to access the wiki through your browser. * `depends_on:`: Specifies that the `web` service depends on the `db` service. Docker Compose will start the `db` service before the `web` service. * `environment:`: Sets environment variables for MediaWiki to connect to the database. * `volumes:`: Mounts a volume to persist the MediaWiki configuration and files.
- `volumes:`: Defines the volumes used for data persistence.
== Starting the Services
1. Save the above content as `docker-compose.yml` in a directory of your choice. 2. Open a terminal and navigate to the directory containing the `docker-compose.yml` file. 3. Run the following command:
```bash docker-compose up -d ```
This command will download the necessary images (if not already present) and start the containers in detached mode (running in the background).
== Accessing MediaWiki
Once the containers are running, open your web browser and navigate to `http://localhost` (or the IP address of your server if you are not running this locally). You should see the MediaWiki setup screen.
== Initial Configuration
Follow the on-screen instructions to configure your MediaWiki installation. You will need to provide information such as:
- Database type (MariaDB)
- Database name (mediawiki)
- Database username (mediawiki)
- Database password (your_mediawiki_password)
- Admin username and password
== Important Considerations
- **Backups:** Regularly back up the `db_data` and `wiki_data` volumes to prevent data loss. You can use tools like `docker volume backup` or simply copy the volume directories.
- **Updates:** To update MediaWiki, stop the containers, pull the latest image (`docker pull mediawiki:latest`), and restart the containers (`docker-compose up -d`). The database will retain your data.
- **Customization:** You can customize the MediaWiki configuration by modifying the `LocalSettings.php` file within the `wiki_data` volume.
- **Security:** Ensure your server is properly secured with a firewall and other security measures.
== Troubleshooting
Problem | Possible Solution |
---|---|
Wiki not accessible in browser | Verify Docker and Docker Compose are running. Check the container logs (`docker-compose logs`). Ensure port 80 is not blocked by a firewall. |
Database connection errors | Double-check the database credentials in the `docker-compose.yml` file and during the MediaWiki setup. Verify the MariaDB container is running. |
Slow performance | Increase the CPU and memory allocated to the containers. Optimize your database queries. |
For further assistance, consult the official MediaWiki documentation and the Docker documentation. Also, consider checking the Stack Overflow website for solutions to common problems.
== Advanced Configuration
For more advanced configurations, you might consider:
- Using a reverse proxy like Nginx or Apache for SSL termination and load balancing.
- Configuring persistent storage with a network file system (NFS).
- Setting up a dedicated volume for uploads.
- Using a different database engine, such as PostgreSQL.
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.* ⚠️