Minecraft has transcended its status as merely a game; it’s a vibrant canvas for creativity, collaboration, and connection—especially for my son, Alexander. For him, Minecraft is more than just building elaborate castles or fending off creepers. It’s a realm where he can explore, learn, and share experiences with his friends.

As a parent, however, I’m acutely aware of the risks associated with public or third-party servers. Concerns about online privacy, intrusive ads, and a lack of control over the gaming environment loom large. That’s precisely why I chose to self-host a Minecraft server for Alexander. This decision not only ensures a safe, private space for him to play, but also allows me to manage the server on our own terms.

And here’s the bonus: using Docker makes the whole process surprisingly straightforward. In this post, I’ll share why self-hosting is a worthy endeavor, how Docker fits into the picture, and provide a step-by-step setup guide to get you started.


Why Self-Host a Minecraft Server?

1. Privacy and Security

Public servers often demand accounts on third-party platforms, exposing players to strangers and increasing the risk of inappropriate interactions or data collection. By self-hosting, you gain control over who accesses the server, ensuring a safer environment for your child.

2. Full Control

With a self-hosted server, you can customize everything—from gameplay rules to mods and plugins. Want a creative-only world? Consider it done. Prefer to whitelist only Alexander’s friends? Easy as pie.

3. No Ads or Hidden Costs

Unlike some third-party services that market themselves as “free” while bombarding players with ads or microtransactions, a self-hosted server is distraction-free and fully under your control.

4. A Learning Opportunity

Setting up a server introduces both Alexander and me to fundamental concepts like hosting, networking, and system administration. It’s a hands-on lesson in how the internet operates.


Why Use Docker for a Minecraft Server?

Docker streamlines the process of running applications such as a Minecraft server by encapsulating them in isolated containers. Here’s why it’s an excellent fit for this purpose:

  • Portability: Docker containers operate the same way across different systems—be it Linux, macOS, or Windows.
  • Ease of Updates: Updating a Docker container is as simple as pulling the latest image.
  • Resource Efficiency: Containers are lightweight, consuming fewer resources than traditional virtual machines.
  • Simplicity: Docker Compose simplifies managing and configuring the server.

Setting Up a Minecraft Server with Docker

Prerequisites

  1. Install Docker and Docker Compose

    • Follow the official Docker installation guide for your operating system.
    • Install Docker Compose by following the provided instructions.
  2. Have a Basic Understanding of Docker Commands
    While this guide will be step-by-step, familiarity with docker and docker-compose commands will be beneficial.


Step 1: Create a Project Directory

Let’s start by creating a directory for your Minecraft server setup:

mkdir minecraft-server
cd minecraft-server

Step 2: Write the Docker Compose File

In your minecraft-server directory, create a file named docker-compose.yml with the following content:

version: '3.8'

services:
  minecraft:
    image: itzg/minecraft-server:latest
    container_name: minecraft_server
    ports:
      - "25565:25565" # Minecraft server port
    environment:
      EULA: "TRUE"               # Accept Minecraft's EULA
      MAX_PLAYERS: 10            # Maximum players
      ONLINE_MODE: "TRUE"        # Enable Mojang account verification
      WHITELIST: "TRUE"          # Enable whitelist
    volumes:
      - ./data:/data             # Persist server data
    restart: unless-stopped

Key Points:

  • EULA: Acceptance of the Minecraft End User License Agreement is mandatory to run a server.
  • ONLINE_MODE: This setting ensures that only legitimate Mojang accounts can connect.
  • WHITELIST: This restricts access to pre-approved players.

Step 3: Start the Server

To start the server, run the following command:

docker-compose up -d

The -d flag runs the container in detached mode, allowing it to operate in the background.


Step 4: Configure the Server

Once the server starts for the first time, it will generate configuration files in the data directory. To edit the whitelist or server settings:

  1. Open the data/whitelist.json file to add approved players (e.g., Alexander and his friends). Example:

    [
      { "uuid": "player-uuid", "name": "PlayerName" }
    ]
    
  2. Modify data/server.properties to customize game settings like difficulty, game mode, and spawn radius.

  3. Restart the server to apply changes:

    docker-compose restart
    

Step 5: Connecting to the Server

  1. Launch Minecraft on Alexander’s computer.
  2. Select Multiplayer > Add Server.
  3. Enter the server address: localhost (if hosting locally) or your LAN/External IP (if hosting remotely).

For external access, you’ll need to configure port forwarding on your router to allow connections to port 25565.


Step 6: Monitor and Maintain the Server

  • Check Logs:
    To troubleshoot, view server logs using:

    docker-compose logs -f minecraft
    
  • Update the Server:
    To update the Minecraft server image, run:

    docker-compose pull
    docker-compose up -d
    
  • Back Up Data:
    Regular backups of the data directory are crucial to preserve worlds and configurations:

    tar -czvf minecraft-backup.tar.gz data/
    

Extra Features to Consider

  • Install Mods or Plugins:
    Consider using Forge or PaperMC (available via the same Docker image) to add mods or plugins for a richer gaming experience.

  • Enable Resource Limits:
    Add resource constraints in your docker-compose.yml to prevent the server from consuming excessive CPU or memory:

    deploy:
      resources:
        limits:
          cpus: "1.0"
          memory: "2G"
    

Final Thoughts

This setup is about more than just playing Minecraft; it’s about crafting a space for creativity, learning, and collaboration while imparting valuable lessons about technology and privacy.

And perhaps most rewarding of all? I can rest easy knowing that Alexander’s digital playground is safe, ad-free, and entirely under our control.