It was time. I’ve been waiting for enough time to learn Docker and begin to get familiar with it. I’ve heard of it, seen it in action, and thought it was the coolest thing in the world and I had to learn it. I decided to take the dive off the actual Docker ship and descend into the depths.
So, I found a YouTube video from the Docker YouTube video channel (link: https://youtu.be/iqqDU2crIEQ). Albeit it provided me some terminology and knowledge, it didn’t really tell me everything I wanted to know, like some under-the-core or how docker did the docker thing. I learned how to build, ps, port forward, docker hub, and a Dockerfile, but then they went to docker-compose and I got lost.
So, after sitting on that video and registering all the information I decided to set a goal: Load minecraft in a docker container. This shouldn’t be difficult, as it requires java, some source files, and that should be simple.
Firstly I had to get myself a Virtual Machine. I fired up VirtualBox and a Centos 7 image with 2 CPU, 4GB RAM, and 20gb of SSD storage. yum update and yum installed docker (2:1.13.1-203.git0be3e21.el7.centos), and I was good to go. Starting the docker service wasn’t really part of the instructions, but on noticing the errors I was getting executing docker I realized it was something that needed to happen.
Getting Minecraft wasn’t difficult, as I just had to go to their Server Download URL and grab the jar. I provided it a eula.txt and a proper server.properties, which is needed for minecraft to properly launch.
Now I had to make myself a Dockerfile. I knew I’d need Java, and hub gave me openjdk:7 to use. The rest of the Dockerfile was to copy files, set the working directory, and then execute Minecraft. I pulled my command-line from my actual Minecraft Server as reference and converted it:
FROM openjdk:7 COPY . . WORKDIR . CMD ["java", "-Xmx2048M", "-Xms2048M", "-jar", "minecraft-server.jar", "nogui"]
On executing the above I got some Java Version issue, and Minecraft wouldn’t launch. Changing openjdk:7 to openjdk:8 solved this quite well.
So, now i’ve got my Docker image launched! After connecting to it and learning that it couldn’t authenticate me due to a failure to connect to the mojang authentication server I learned that Docker is dependent on the machines network, including DNS, and I failed to set up DNS. On setting up a correct /etc/resolve.conf and restarting the image I was able to connect to my first Docker minecraft server!
On pulling up some system resources I learned that Java was actually allocating all the ram that I specified on the command-line (50% of the VM), and I didn’t really think it needed to be doing that at the start. On removing the -Xmx and -Xms parameters and rebuilding it seemed the application still loaded, but just ran with <20% of the necessary RAM.
There is no current disk persistence of the world, which would be a logical next step. For now, Take 1 was successful!