Skip to content

Repository files navigation

Minecraft Server Setup And Containerization

This repository serves as a guide for containerizing a simple Minecraft Server: Java Edition using Docker Compose.

This Repository was created as part of my training at the Developer Academy.

Table of Contents

  1. Prerequisites
  2. Description
  3. Quickstart
  4. Usage
  5. Additional Notes

Prerequisites

Description

Minecraft

Minecraft is a popular sandbox game that allows players to explore, build, and adventure in their own worlds. Alone or in multiplayer mode.

Minecraft Server

A Minecraft Server is a program that allows players to play Minecraft online in a multiplayer environment. A server hosts these worlds and allows multiple players to connect and play together at the same time. A Minecraft Server typically runs on a dedicated computer or virtual machine and can be operated in various configurations. Players connect to the server via its IP address and port.

If you want to use mods and/or plugins, there are something to keep in mind:

  • Standard Minecraft Server software (vanilla) - that is used here - does not support mods, only the basic functions of the game.

    • You can customize the game a little using data packs and configuration files (like server.properties) (e.g. the number of players allowed, etc.)
  • To use mods and/or plugins you must use an advanced server:

Minecraft Server Edition

There is the Java Edition and the Bedrock Edition of Minecraft - two different versions of the game that differ in technology, features and compatibility.

This repository containerizes the Java Edition Server:

  • only suitable for the PC
  • runs via the Java Runtime Environment (JRE)
  • easy to set up
  • saves resources

Tip

If you are interested in a cross-platform application, for example because you want to play Minecraft on a console, you need the Bedrock Server.

Quickstart

This section provides a fast and minimal setup guide for using the tools in this repository. For a more in-depth understanding and additional options, please refer to the Usage section.

  1. Clone the project to your platform if you just want to use it:

    • Example: Clone the repo e.g. using an SSH-Key:
    git clone git@github.com:MarcelDechant/minecraft_server.git
  2. Navigate into the project directory Change into the cloned project directory:

    cd minecraft_server
  3. Download the Java Server file from the Minecraft webpage. For copyright reasons, the server file will not be uploaded to github.:

    https://www.minecraft.net/de-de/download/server
  4. Make the file executable if necessary:

    chmod +x server.jar
  5. Create your .env file from the provided template:
    This file contains configuration values for your Minecraft server such as player limits, seed, and view distance.

    cp example.env .env

    You can edit the file using a text editor:

    nano .env

    Example contents:

    MAX_PLAYERS=10
    LEVEL_SEED=4025804172371830787
    VIEW_DISTANCE=10
  6. Build and start the container in the background (detached mode):

    docker compose up --build -d
  7. Check whether the server is running correctly:

  • If you have a Minecraft account: You can connect to the server on your cloud VM from your Java Minecraft client on your computer and play Minecraft.

  • If you don’t have a Minecraft account, you can check whether the server is online using this tool: use a website that shows the status of Minecraft servers or try to establish a connection to the Minecraft server using the Python mcstatus module.

Note

The Minecraft server can be reached under the IP address of your cloud VM on port 8888: http://IP_Address_VM:8888

Usage

Installation and Preparation

  1. Clone the project to your platform:

    • Example: Clone the repo e.g. using an SSH-Key:
    git clone git@github.com:MarcelDechant/minecraft_server.git
  2. Download the Java Server file from the Minecraft webpage. For copyright reasons, the server file will not be uploaded to github.:

    https://www.minecraft.net/de-de/download/server
    • Don't forget to move the server file to the project folder, e.g. from Windows PC to a VM via SSH:
      • scp /path/to/minecraft_server/server.jar username@vm-ip:/path/to/minecraft_server
  3. It may be that the server file needs to be made executable:

    • View rights of the files in the directory:
    ls -l
    • For the server.jar file it should look like this:

      • -rwxr-xr-x
    • Set execute permissions if they don't exist:

    chmod +x server.jar
  4. Create the environment configuration file:
    Use the included example.env to create your .env file.

    cp example.env .env

    Edit the file to adjust values as needed (you can use nano, vim, etc.):

    MAX_PLAYERS=10
    LEVEL_SEED=4025804172371830787
    VIEW_DISTANCE=10

Containerization with Docker Compose

  1. The Dockerfile describes how a single Docker image should be created. It serves as the basis for a service in the Docker Compose file.

  2. The compose.yaml is responsible for managing and orchestrating the Minecraft Server container. It defines what configurations it should have.

  3. The server.properties file plays a central role in setting up a Minecraft Java server. It contains the configuration options that allow you to customize the behavior of the server, the game rules and the technical characteristics.

    • You can read about which properties can be changed here.
    • Here are some nice starter Seeds
  4. Build and start the container in the background (detached mode):

    docker compose up --build -d
    • To view the log files:

      docker compose logs -f
    • To stop the container:

      docker compose stop <container-name>
    • To delete the container:

      docker compose down <container-name>
    • To list all containers that are operatet by Docker Compose:

      docker compose ps
  5. Check whether the server is running correctly:

  • If you have a Minecraft account: You can connect to the server on your cloud VM from your Java Minecraft client on your computer and play Minecraft.

  • Use a website that offers status checks for Minecraft Servers or try to establish a connection to the Minecraft Server using the python mcstatus module.

    • mcstatus.io: mcsrv

Note

The Minecraft server can be reached under the IP address of your cloud VM on port 8888: http://IP_Address_VM:8888.
The ERR_EMPTY_RESPONSE error message means that the browser tried to communicate with the server but did not receive any data. This is to be expected since a Minecraft Server doesn't send HTTP data that a browser can interpret. The Minecraft server uses Minecraft's own protocol, which is not compatible with a web browser.The Minecraft Server is running correctly and listening on the specified port (e.g. 8888), but it only responds to requests from Minecraft clients, not HTTP requests.
ip_address:8888

Additional Notes

Alternative:
You can work with the Docker Minecraft Server that uses the base image itzg/minecraft-server. This image already containes the server file and the java environment.

The Minecraft Wiki offers a setup for this but points out that the contents of this setup are not supported by Mojang Studios or the Minecraft Wiki.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages