- Overview
- Why Use Docker for Minecraft Server?
- Prerequisites
- Tested On
- Installation
- Usage
- Uninstallation
- Troubleshooting
- Additional Information
This project provides a Docker setup for running a Minecraft server. It simplifies the process of setting up and managing Minecraft servers by using Docker, making it easier to deploy and maintain different Minecraft server versions and modpacks.
Running a Minecraft server in a Docker container offers several advantages:
- Isolation: Each server runs in its own environment, reducing conflicts with other software.
- Portability: Easily move your server setup between different machines.
- Consistency: Ensure that the server runs in the same environment every time, reducing issues related to system differences.
- Git and Docker Engine installed on your machine.
- Basic familiarity with Docker commands.
Ubuntu Server 22.04 with:
- All the Mods 9-0.3.2
- All the Mods 10-0.52
- Better MC [FORGE] BMC4 v32.5
- Paper 1.21.1
- RLCraft 1.12.2 - Release v2.9.3
- Vanilla 1.21.1
-
Clone the Repository
git clone https://github.com/FilipRokita/minecraft-server-docker
-
Rename the Repository Folder
mv minecraft-server-docker mcsrv
-
Edit Dockerfile (if needed)
- Open the
Dockerfile
and locate the line that installs Java:RUN apt-get update && \ apt-get install -y curl openjdk-21-jdk wget
- If you are running an older version of Minecraft, change the Java version to
openjdk-8-jdk
. Additionally, if your server requires extra packages (such asunzip
) add them to this line. For example:Some servers might work with onlyRUN apt-get update && \ apt-get install -y curl openjdk-8-jdk wget unzip
openjdk-X-jre-headless
installed, but you’ll need to experiment to find what works best.
- Open the
-
Build Container and Create Symlink
- From inside the
mcsrv
directory, create a symlink to the Docker volume for easy access to your data:docker compose up -d --build && docker compose down ln -s /var/lib/docker/volumes/mcsrv_data/_data data
- Note: The path to the volume may vary. You can check the exact path using
docker volume inspect mcsrv_data
- From inside the
-
Download Server Files
- Download the Minecraft server files or modpack server files.
- Place the
.jar
file or unzipped files into thedata
folder.
-
Run Docker Container
docker compose up -d
Note: You must run this command inside
mcsrv
folder -
Attach to the Container
docker attach mcsrv-mc-1
You are now in the Docker container.
-
Initial Server Configuration
- Follow the server or modpack guide for the initial setup. If no guide is available, common steps include:
- Run
java -jar server.jar
. - Accept the EULA by editing
eula.txt
.echo eula=true > eula.txt
- Create a
run.sh
script with:Note: Adjustjava -Xmx8G -jar server.jar nogui
-Xmx8G
to match the amount of RAM your server will use (in this case, 8GB).
- Run
- Run the server manually for the first time, wait until the world generates, and stop it with
stop
.
- Follow the server or modpack guide for the initial setup. If no guide is available, common steps include:
-
Detach and Stop the Container
- Use
Ctrl + P
, thenCtrl + Q
to detach from the container. - Run this command inside
mcsrv
folder to stop the container:docker compose down
- Use
-
Finalize Docker Configuration
- Edit the
Dockerfile
to uncomment theCMD
line and ensure it points to yourrun.sh
script. - If necessary, modify the line to match the script provided by the modpack. (e.g,
startserver.sh
,start.sh
, etc.)
- Edit the
-
Start Server
docker compose up -d
Note: If you are running this command for the first time after installation, use
docker compose up -d --build
. Also, ensure you are executing the command inside themcsrv
folder. -
Stop Server
docker attach mcsrv-mc-1 stop docker compose down
-
Stop Server (Emergency)
docker compose down
Note: Use this command inside
mcsrv
folder if the server is unresponsive or crashes. -
Access Server Console
docker attach mcsrv-mc-1
-
Exit Console
- Use
Ctrl + P
, thenCtrl + Q
.
- Use
-
Remove Folder
rm -rf mcsrv
-
Remove Docker Container, Image, and Volume
docker container rm -f mcsrv-mc-1 docker image rm mcsrv-mc docker volume rm mcsrv_data
For issues or questions, refer to:
Version: 1.0.21
Date: 2024-09-18
License: MIT License
Author: Filip Rokita