How to Use Docker on a Rented Server

From Server rental store
Jump to navigation Jump to search
  1. How to Use Docker on a Rented Server

This article will guide you through setting up and using Docker on a rented server. Using Docker simplifies application deployment and management by containerizing applications and their dependencies. This tutorial assumes you have basic familiarity with the command line and SSH.

== Prerequisites

Before you begin, ensure you have the following:

== Step 1: Connecting to Your Server

Use an SSH client (like PuTTY on Windows or the terminal on macOS/Linux) to connect to your server. You will need the server's IP address and your login credentials.

``` ssh username@server_ip_address ```

== Step 2: Installing Docker

The installation process varies slightly depending on your server's operating system.

Ubuntu/Debian

Update the package list:

```bash sudo apt update ```

Install Docker:

```bash sudo apt install docker.io ```

Verify the installation:

```bash docker --version ```

CentOS/RHEL

Update the package list:

```bash sudo yum update ```

Install Docker:

```bash sudo yum install docker ```

Start and enable Docker:

```bash sudo systemctl start docker sudo systemctl enable docker ```

Verify the installation:

```bash docker --version ```

Adding Your User to the Docker Group

To run Docker commands without `sudo`, add your user to the `docker` group:

```bash sudo usermod -aG docker $USER newgrp docker ```

You may need to log out and log back in for the group change to take effect.

== Step 3: Understanding Docker Concepts

Before running containers, it's essential to understand a few key concepts:

  • **Images:** Read-only templates containing the application and its dependencies.
  • **Containers:** Runnable instances of an image.
  • **Docker Hub:** A public registry for Docker images.
  • **Docker Compose:** A tool for defining and running multi-container Docker applications.

== Step 4: Running a Simple Container

Let's run a simple "hello-world" container to test your setup:

```bash docker run hello-world ```

This command will download the `hello-world` image from Docker Hub (if it's not already present) and run it. You should see a message confirming that Docker is working correctly.

== Step 5: Running a MediaWiki Container

You can use pre-built Docker images for MediaWiki. Here's an example using a common image. Remember to configure persistent storage for your wiki data (see Step 6).

```bash docker run -d --name mediawiki -p 80:80 -e MW_ADMIN_USER=admin -e MW_ADMIN_PASSWORD=password dhrp/mediawiki ```

This command does the following:

  • `-d`: Runs the container in detached mode (in the background).
  • `--name mediawiki`: Assigns a name to the container.
  • `-p 80:80`: Maps port 80 on the host server to port 80 in the container. Access your wiki via `http://server_ip_address`.
  • `-e MW_ADMIN_USER=admin`: Sets the initial admin username.
  • `-e MW_ADMIN_PASSWORD=password`: Sets the initial admin password. **Change this for security!**
  • `dhrp/mediawiki`: Specifies the Docker image to use.

== Step 6: Persistent Storage

By default, data inside a container is lost when the container is stopped or removed. To prevent this, use Docker volumes to persist your MediaWiki data.

Create a volume:

```bash docker volume create mediawiki_data ```

Run the MediaWiki container with the volume mounted:

```bash docker run -d --name mediawiki -p 80:80 -e MW_ADMIN_USER=admin -e MW_ADMIN_PASSWORD=password -v mediawiki_data:/var/www/html dhrp/mediawiki ```

This mounts the `mediawiki_data` volume to the `/var/www/html` directory inside the container, where MediaWiki stores its files.

== Step 7: Docker Compose (Optional)

For more complex setups, use Docker Compose to define and manage your application. Create a `docker-compose.yml` file:

```yaml version: "3.9" services:

 mediawiki:
   image: dhrp/mediawiki
   ports:
     - "80:80"
   environment:
     MW_ADMIN_USER: admin
     MW_ADMIN_PASSWORD: password
   volumes:
     - mediawiki_data:/var/www/html

volumes:

 mediawiki_data:

```

Then, run:

```bash docker-compose up -d ```

== Server Resource Considerations

The following table outlines typical resource requirements for a basic MediaWiki installation using Docker:

Resource Minimum Recommended High Usage
CPU 1 Core 2 Cores 4+ Cores
RAM 1 GB 2 GB 4+ GB
Disk Space 20 GB 50 GB 100+ GB

== Security Considerations

  • **Change Default Credentials:** Always change the default admin username and password.
  • **Firewall:** Configure a firewall (like `ufw` on Ubuntu) to restrict access to your server.
  • **Regular Updates:** Keep your server's operating system and Docker updated with the latest security patches.
  • **HTTPS:** Implement HTTPS using a service like Let's Encrypt to encrypt traffic between your server and users.

== Troubleshooting

Problem Possible Solution
Container won't start Check Docker logs using `docker logs <container_id>`. Verify the image exists on Docker Hub.
Can't access MediaWiki in browser Verify the port mapping is correct (`-p 80:80`). Check your server's firewall.
Data is lost when container stops Ensure you are using Docker volumes for persistent storage.

== Further Reading


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