Minecraft server
Long time ago, in a time before Microsoft bought Mojang, my son liked Minecraft and asked me if it is difficult to set a server. As the server is written in Java (as the game), I anwsered “no”. Then, of course, I had to demonstrate my point of view :-)
Minecraft server in Docker
I want initially several things:
- reasonable security
- easy to set up on one of my home low power computer
- I already use a lot virtual machine like qemu, virtualbox and bochs, thus I want to try new stuff
Docker give me:
- containment with LXC
- easy to set up
- easy to maintain and interact with
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
- install java (apt-get)
- set up a user toto with the UID (1003 in example) you plan to use
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.
tmux
start_sc
Systemd
A systemd script would be nice for automatic start would be nice.