Containerization (Docker)

From Server rental store
Revision as of 09:57, 15 April 2025 by Admin (talk | contribs) (Automated server configuration article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. Containerization (Docker) for MediaWiki

This article provides a technical overview of using containerization, specifically Docker, for deploying and managing a MediaWiki installation. Containerization offers significant advantages over traditional deployment methods, including consistency, portability, and scalability. This guide is aimed at system administrators and developers new to Docker but familiar with basic server administration concepts.

What is Containerization?

Containerization is a form of operating system virtualization. Unlike virtual machines (VMs) which virtualize hardware, containers virtualize the operating system. This means containers share the host OS kernel, making them lightweight and efficient. Each container packages an application with all its dependencies—libraries, frameworks, configuration files—into a single, executable package. Virtualization is a related but distinct concept.

Docker is the most popular containerization platform. It allows you to create, deploy, and run applications in isolated environments called containers.

Why Use Docker with MediaWiki?

Several benefits make Docker an excellent choice for MediaWiki deployments:

  • **Consistency:** Ensures the same environment across development, testing, and production. This eliminates the "works on my machine" problem.
  • **Portability:** Containers can run on any system that supports Docker, regardless of the underlying infrastructure. This simplifies migrations and scaling.
  • **Isolation:** Containers isolate applications from each other and the host system, improving security and stability.
  • **Scalability:** Docker facilitates easy scaling of MediaWiki instances through orchestration tools like Docker Compose or Kubernetes.
  • **Simplified Deployment:** Docker simplifies the deployment process, reducing the risk of errors.

Pre-requisites

Before you begin, you will need the following:

  • A server with a supported operating system (Linux is recommended).
  • Docker installed and running on your server. Refer to the official Docker documentation for installation instructions: [1](https://docs.docker.com/get-docker/)
  • Docker Compose installed (optional, but highly recommended for multi-container setups).
  • Basic familiarity with the command line.
  • A basic understanding of PHP and MySQL/MariaDB.


Setting up a MediaWiki Container

The most common approach involves utilizing a pre-built Docker image or creating your own. We will focus on using a pre-built image as it's the simplest method for beginners.

Using a Pre-built Image

Several pre-built MediaWiki Docker images are available on Docker Hub. These images typically include the necessary web server (Apache or Nginx), PHP, and database client.

Here's an example using a popular image:

```bash docker run -d -p 80:80 -p 443:443 -v /path/to/mediawiki/data:/var/www/html/data --name mediawiki mediawiki-official/mediawiki:latest ```

Let’s break down the command:

  • `docker run`: Starts a new container.
  • `-d`: Runs the container in detached mode (in the background).
  • `-p 80:80`: Maps port 80 on the host to port 80 in the container (HTTP).
  • `-p 443:443`: Maps port 443 on the host to port 443 in the container (HTTPS).
  • `-v /path/to/mediawiki/data:/var/www/html/data`: Mounts a volume from the host (`/path/to/mediawiki/data`) to the container (`/var/www/html/data`). This is crucial for persistent storage of MediaWiki data (images, files, etc.). Replace `/path/to/mediawiki/data` with the actual path on your host system.
  • `--name mediawiki`: Assigns a name to the container.
  • `mediawiki-official/mediawiki:latest`: Specifies the Docker image to use.

After running this command, your MediaWiki instance should be accessible in your web browser at `http://your_server_ip` (or `https://your_server_ip` if you've configured SSL).


Database Configuration

The above example assumes a database server is already running. You can either connect to an existing database or run a separate database container. Here's a table summarizing typical database connection details:

Database Type Host Port Username Password Database Name
MySQL localhost 3306 root your_root_password wikidb
MariaDB localhost 3306 root your_root_password wikidb

You'll need to configure MediaWiki's `LocalSettings.php` file (located within the mounted volume) with these details.

Using Docker Compose

Docker Compose simplifies managing multi-container applications. You can define your MediaWiki setup (web server, database, etc.) in a `docker-compose.yml` file.

Here’s a basic example:

```yaml version: "3.9" services:

 db:
   image: mariadb:10.6
   restart: always
   environment:
     MYSQL_ROOT_PASSWORD: your_root_password
     MYSQL_DATABASE: wikidb
     MYSQL_USER: wikiuser
     MYSQL_PASSWORD: your_wiki_password
   volumes:
     - db_data:/var/lib/mysql
 mediawiki:
   image: mediawiki-official/mediawiki:latest
   restart: always
   ports:
     - "80:80"
     - "443:443"
   depends_on:
     - db
   volumes:
     - mediawiki_data:/var/www/html/data
   environment:
     MW_DB_TYPE: mariadb
     MW_DB_SERVER: db
     MW_DB_NAME: wikidb
     MW_DB_USER: wikiuser
     MW_DB_PASSWORD: your_wiki_password

volumes:

 db_data:
 mediawiki_data:

```

To start the application, run `docker-compose up -d`. This will create and start the database and MediaWiki containers, linking them together.

Technical Specifications Summary

Here's a summary of typical technical specifications for a Dockerized MediaWiki setup:

Component Specification Notes
Docker Engine Version 20.10.0 or later Latest stable version recommended
Operating System Linux (Ubuntu, Debian, CentOS, etc.) Windows and macOS are also supported, but Linux is preferred for production
Web Server Apache or Nginx Included in most MediaWiki Docker images
PHP Version 7.4 or 8.1 Check MediaWiki requirements for compatibility
Database MySQL or MariaDB MariaDB is often preferred due to its open-source nature

And a table outlining resource requirements:

Resource Minimum Recommended
CPU 1 Core 2+ Cores
RAM 1 GB 4+ GB
Disk Space 20 GB 50+ GB (depending on content)

Finally, a table showing common ports used:

Port Protocol Description
80 TCP HTTP (Web Access)
443 TCP HTTPS (Secure Web Access)
3306 TCP MySQL/MariaDB Database

Further Considerations

  • **SSL/TLS:** Secure your MediaWiki instance with SSL/TLS certificates. Let's Encrypt provides free certificates.
  • **Backups:** Implement a regular backup strategy for your MediaWiki data and database.
  • **Monitoring:** Monitor your containerized MediaWiki instance for performance and health.
  • **Updates:** Regularly update your Docker images to benefit from security patches and new features. Consider automating this process.
  • Security Best Practices are essential when deploying any web application.



MediaWiki Docker Docker Compose Kubernetes Virtualization PHP MySQL MariaDB Apache Nginx Let's Encrypt LocalSettings.php Docker Hub Security Best Practices Deployment Scaling Troubleshooting


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?

⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️