mide/minecraft

By mide

Updated over 3 years ago

Docker Image to run a Minecraft Server

Image

10K+

Minecraft Docker Image

DockerDockerGitHub licenseGitHub issuesBuild Status

Motivation

There are many Minecraft Docker images already developed, why develop another?

From what I was able to find, no Minecraft Docker image currently handles signals. That means when a docker stop command is issued, Docker will attempt to signal the process to gracefully quits, but the process ignores it. Docker then terminates the server without the Minecraft server saving the state, leaving the potential of corrupted data.

By writing a simple wrapper (wrapper.py), this image is able to process the SIGTERM signal that is sent by Docker during a docker stop command. That is then turned into an RCON call, which instructs the server to safely exit and close.

In order to keep simplicity, the container will be mounted to paths on the host disk. This will allow existing automation that manages things like ops.txt or server.properties to continue to work.

Usage (Vanilla Minecraft)

# Copy configuraitons into Minecraft directory (If you have automation in
# place, run that here; that shouldn't need to change).
mkdir -p /srv/minecraft/
cp ~/my_server.properties /srv/minecraft/server.properties
echo "eula=true" > /srv/minecraft/eula.txt"

# Start Minecraft Server
docker run \
  -e MINECRAFT_VERISON=1.11.2 \
  -v /srv/minecraft/:/minecraft/:rw \
  --publish 25565:25565 \
  mide/minecraft:latest

Options & Settings

Required
OptionExpected ValueLocation
enable-rcontrueserver.properties
rcon.passwordYour RCON Passwordserver.properties
rcon.portYour RCON Portserver.properties
eulatrueeula.txt
MINECRAFT_VERSIONSomething like 1.11.2Environment Variable
Optional
OptionDescriptionDefault ValueLocation
JAVA_TOOL_OPTIONSJVM Settings, like heap size-Xmx1024M -Xms1024MEnvironment Variable
broadcast-rcon-to-opsAnnounce RCON commands to Server Opsfalse ??? TODOserver.properties

Docker Pull Command

docker pull mide/minecraft