Docker Basics

From Server rental store
Jump to navigation Jump to search
  1. Docker Basics

This article provides a foundational understanding of Docker containers, geared towards newcomers to server administration and deployment within our MediaWiki environment. Docker simplifies application deployment and management by packaging software into standardized units called containers. This ensures consistency across different environments, from development to production. Understanding Docker is becoming increasingly vital for maintaining and scaling our MediaWiki infrastructure.

What is Docker?

Docker is a platform for developing, shipping, and running applications in isolated environments called containers. Think of containers as lightweight virtual machines. However, unlike virtual machines which virtualize hardware, containers virtualize the operating system. This makes them significantly more efficient and faster to start. Docker utilizes the operating system's kernel and doesn't require the overhead of a full virtual machine. This is particularly useful for running multiple instances of applications like Apache or MySQL efficiently.

Core Concepts

Several core concepts underpin Docker’s functionality:

  • Images: Read-only templates containing the instructions for creating a container. Images are built from a `Dockerfile`.
  • Containers: Runnable instances of an image. They encapsulate an application and its dependencies.
  • Dockerfile: A text file that contains the instructions to build a Docker image.
  • Docker Hub: A public registry for Docker images. You can also create private registries.
  • Volumes: Persistent storage mechanisms used to store data generated by containers, independent of the container lifecycle. Crucial for database data in MariaDB.
  • Networks: Allow containers to communicate with each other and the outside world. Often used for connecting PHP containers to database containers.

Basic Docker Commands

Here's a rundown of essential Docker commands:

  • `docker pull <image_name>`: Downloads an image from a registry. Example: `docker pull ubuntu:latest`
  • `docker run <image_name>`: Creates and starts a container from an image.
  • `docker ps`: Lists running containers.
  • `docker ps -a`: Lists all containers (running and stopped).
  • `docker stop <container_id>`: Stops a running container.
  • `docker start <container_id>`: Starts a stopped container.
  • `docker rm <container_id>`: Removes a container.
  • `docker images`: Lists available images.
  • `docker rmi <image_id>`: Removes an image.
  • `docker build -t <image_name> .`: Builds an image from a `Dockerfile` in the current directory.

Example: Running a Simple Nginx Container

Let's illustrate with a basic example. We'll run a simple Nginx web server container.

1. Pull the Nginx image:

   ```bash
   docker pull nginx:latest
   ```

2. Run the container:

   ```bash
   docker run -d -p 8080:80 nginx:latest
   ```
   This command does the following:
   *   `-d`: Runs the container in detached mode (in the background).
   *   `-p 8080:80`: Maps port 80 inside the container to port 8080 on the host machine.

3. Access the Nginx server:

   Open a web browser and navigate to `http://localhost:8080`. You should see the default Nginx welcome page.

Docker Networking

Containers often need to communicate with each other. Docker provides networking features to facilitate this. By default, containers are connected to a default network. However, you can create custom networks for more control and isolation. This is vital when setting up a LAMP stack.

Network Type Description
Bridge The default network type. Creates a private internal network.
Host The container shares the host's network namespace.
None The container has no network interface.

Docker Volumes

Data within a container is ephemeral, meaning it's lost when the container is stopped or removed. Docker volumes provide a way to persist data beyond the container lifecycle. Volumes are stored on the host machine and can be shared between containers. Essential for preserving MediaWiki data.

Volume Type Description
Named Volumes Volumes created with a specific name. Easier to manage.
Bind Mounts Mount a file or directory from the host machine into the container.
tmpfs Mounts Create temporary file systems inside the container.

Dockerfile Example

Here's a simple example of a `Dockerfile` for a basic PHP application:

```dockerfile FROM php:7.4-apache

COPY . /var/www/html/

EXPOSE 80 ```

This `Dockerfile` does the following:

  • `FROM php:7.4-apache`: Uses the official PHP 7.4 image with Apache as the base image.
  • `COPY . /var/www/html/`: Copies the current directory's contents to the web root of the Apache server.
  • `EXPOSE 80`: Exposes port 80, the default port for HTTP.

System Requirements for Docker

Docker has specific system requirements depending on your operating system. The following table summarizes the key requirements for common operating systems.

Operating System Requirements
Linux Kernel version 3.10 or higher. Requires `cgroup` support.
macOS Docker Desktop for Mac. Requires virtualization support.
Windows Docker Desktop for Windows. Requires Windows 10 Pro/Enterprise or Windows Server 2016 or higher with Hyper-V enabled.

Resources for Further Learning

Conclusion

Docker is a powerful tool for modern application deployment and management. By understanding the core concepts and commands outlined in this article, you'll be well-equipped to utilize Docker within our server infrastructure and contribute to a more efficient and scalable MediaWiki environment. Further exploration of containerization will be beneficial as we continue to modernize our system.


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.* ⚠️