How To Host A DIY Minecraft Server At Home With Docker


My oldest child recently got into Minecraft. My son however, plays Bedrock Edition on an iPad and a game console. He prefers Java Edition on an older computer. (And he can launch it via the terminal! ) To play with each other I thought about running a Dockerized Minecraft server on my home server, and it was much easier than I expected.



A dedicated server is running



The server distribution that is officially available is one Java jar, which means it should be easy to run. 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 and/or daemonize it. But, I've been keeping it simple with docker compose in a byobu session.



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



There are a ton of configuration options to choose from, but I'd like to emphasize two things that I mentioned above:



Game's persistent data are stored on a volume that is mounted on the host. This lets us quickly access the files. The "WORLD" option lets you import a save created on a different computer.



Connecting to the Server



After a few seconds, the server is ready to accept connections, however my clients don't seem to see it for some reason. Minecraft will remain on the "Scanning games on your local network" screen for ever. You can "Add Server" to manually add it, and voila!



Web Map



The majority of my Minecraft knowledge is more than a decade out of date. Third-party tools can provide a web view of a Minecraft environment that is similar to Google Maps. After pnp89's blog of research, it seems like Minecraft Overviewer is the prominent one these days.



While the installation process is simple, I came across an Docker file that was more simple. This is a one-shot (not an ongoing) process so we'll use docker to run:



Leaflet will create a web map that has read-only access to game data from the other container, and another volume to write it to. This directory could be linked to a web-served directories on the host, such as /var/www/public_html, for easy access from any internet browser.



Even though it only takes just a few minutes but the results are impressive.



Makefile



In the end, in line with my own wishes I added a few shortcuts to the Makefile to make it easier to access.



Reasons You Might Want to Build Dockerized Minecraft Server



A dedicated server built by yourself is probably not needed by the majority of people. If you're just looking to play locally with multiplayer and one of your computers is powerful enough you can click "Open to the LAN" directly from the game. A paid hosted server is more suitable for those who wish to play with a greater amount of players from outside your home. This could be the official "Realms" or any of several third-party options.