Containerisation with Docker Part Two

Having successfully got WordPress and MariaDB running in Docker containers and talking to each other so they could host this very website my attention turned to what else I could run in a Docker container that might be useful.

My son is, like most children his age, interested in Minecraft. Minecraft can be played on a variety of different platforms from mobiles to laptops to games consoles. Generally these games are played in isolation or via a direct invitation between two or more players but there is another option which is to have a server that one or more players can connect to. That doesn’t rely on any one player having to host a game.

Interestingly there are several pre-built Docker containers for Minecraft servers. The most popular seems to be https://hub.docker.com/r/itzg/minecraft-bedrock-server. Note that I’ve chosen one that mentions “bedrock”. There are two types of server one for Java edition which can only be used from the Java version of Minecraft which runs on PC and the other is used by the console, Windows 10 and mobile editions and that is the one known as Bedrock edition.

As I had done previously I created a folder on the host VPS server that would hold the data for the Minecraft container so that we could control settings on it and enable it to persist across container restarts. I mapped this folder to the container using the settings in the Plesk control panel and then set an environment variable called EULA and set the value to True which is required to make a Minecraft server start successfully. I also configured the appropriate port and allowed it through the Plesk and IONOS firewalls.

I started up the container and watched the logs report a successful startup. Then it was time to try and connect to it. This was surprisingly difficult because Microsoft don’t allow users to specify servers on Xbox One edition. However as is often the case someone ingenious on the internet had provided a workaround and we were soon able to find a way to connect to our server and my son was able to start doing some work on the world generated on the server.

The next task was to prevent the entire internet from connecting to the server. There is an in-built way of doing this by using a file named whitelist.json which contains a list of known Minecraft users who can access the server but this relies on all users having Microsoft / Mojang accounts which not all of my son’s friends had. This meant we had to go slightly old school and use a firewall restriction in the Plesk control panel so after teaching some 12 year olds how to use What’s my IP we had a list that we could use to restrict access to only those that were permitted to connect.