Minecraft server

My son likes Minecraft and ask me if it is difficult to set a server. As the server is written in Java (as the game), I anwser “no”. Then, of course, I have to demonstrate my point of view :-)

Minecraft server in Docker

I want initially several things:

Docker give me:

how to set it up

I use Debian Linux. The server will write its state in the working directory. The directory is a plain standard directory, and is owned by the user with the UID 1003.

the docker part

debootstrap sid sid
tar -C sid cvf - . | docker import - sidjava

Then you have to install and set up few things

docker run -i -t sidjava bash
root@COMMITVALUE# apt-get install openjdk-8-jre
root@COMMITVALUE# adduser --uid 1003 toto 
docker commit COMMITVALUE sidjava

the main directory

Then you have to store the java server from Mojang in the directory (named here mined). A simple script (sc) to start the java it is useful. It will be executed in the docker.

cd /opt/mined
exec java -Xms1G -Xmx2G -d64 -o true -jar minecraft_server.jar

start the docker image

the starting script (start_sc)
bc.. docker run -t -i sidjava -u toto -v /PATHTO/mined:/opt/mined /opt/mined/sc

I like to start it in a tmux session. This allow easy modification of the server settings.



A systemd script would be nice for automatic start would be nice.