How To Host A DIY Minecraft Server At Home Using Docker


My oldest child recently got into Minecraft. While a lot of his friends play Bedrock Edition on an iPad or game console, my son is playing the venerable Java Edition on an old computer. (And he can launch it via the terminal! ) To play together, I looked into running a Dockerized Minecraft server on my home server and it was more straightforward than I anticipated.



Operating a dedicated server



The official server distribution comes with only one Javajar. It should be simple to use. Before trying it, though, I searched for Docker images, and found a good one: itzg/minecraft-server.



You can start the container by using an individual docker run command or daemonize it. I prefer to keep it simple and set docker compose in my byobu session.



Here's my current docker-compose.yml file:



There are tons of available configuration options, but I'd like to focus on two points above:



- Game's persistent data are written to a disk that is mounted on the host. This allows us to quickly access the files. - The "WORLD" option is useful to import the save file that was originally created on a different computer.



Connecting to the Server



The server will accept connections within a couple of seconds. However my clients aren't in a position to see it. https://irc101.org/ will be on the "Scanning for games on your local network" screen for the rest of the time. You can still "Add Server" to manually add it, and voila!



Web Map



My Minecraft knowledge is about a decade old. However, I'm aware that third-party tools can create an online view of the Minecraft world similar to those in Google Maps. After a bit of research, it seems like Minecraft Overviewer is the prominent one in the present.



While the installation process is straightforward, I found a Docker file that was even more simple. This one's a one-shot process (not an ongoing service), so we'll make use of docker run:



Given read-only access to the game data created by the other container and another volume to write to, this will create a web map with Leaflet. The directory is then symlinked into a web-served directory on the host such as /var/www or ~/public_html for access to any web browser.



While it only takes a few minutes however, the results are impressive.



Makefile



Finally, as is my wont I added some shortcuts into the Makefile for easy access:



The Reasons to build a Dockerized Minecraft Server



Most people don't need a dedicated server. If you are just looking to play locally with multiplayer and your computer is sufficiently powerful you can click "Open to LAN" directly from the game. If you're planning to play with a large group of people outside your home it's best to go with a paid-for hosted server. This could be the official "Realms" or one of a variety of third-party options.