How To Host A DIY Minecraft Server At Home With Docker

From World History
Jump to: navigation, search

My oldest child recently got into Minecraft. Minecraft servers While many of his peers play Bedrock Edition on an iPad or game console, my son plays the classic Java Edition on an old computer. He launches it from his terminal! ) To play together, I looked into running an Dockerized Minecraft server on my home server, and it was much easier than I expected.



Running a Dedicated Server



The official server distribution includes a single 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 either open the container by using the docker run command, or daemonize it. I prefer to keep it simple and set docker compose within my byobu session.



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



There are many possible configuration options, however I'd like to highlight two things above:



The game's data that is persistent is stored on a volume connected to the host to allow us to easily access the files. The "WORLD" option is useful for importing an existing save created on another computer.



Connecting to the Server



After a couple of seconds, the server is ready to accept connections, but my clients aren't able to recognize it for some reason. Minecraft will be on the "Scanning for games on your local network" screen for the rest of the time. No matter, you can "Add Server" to add it manually, and voila!



Web Map



The majority of my Minecraft knowledge is more than a decade out of date. Third-party tools can create a web view of a Minecraft environment similar to Google Maps. It seems that Minecraft Overviewer is the most popular tool nowadays.



As before, this tool's installation is pretty simple, but I found an Docker image that's a lot easier. This is a one-shot procedure (not an ongoing service) So we'll make use of docker run:



With read-only access to game data generated by the other container and another volume to write to, this will result in a web map with Leaflet. This directory can be symlinked to a web-served directories on the host, like /var/www/public_html, for easy access from any web browser.



Although it takes only just a few minutes to complete, the results are quite impressive. Proximal's Blog



Makefile



As is my wont, I threw several shortcuts in the Makefile to make them easy to access:



The Reasons to build Dockerized Minecraft Server



Most people don't require an individual server. If you're just looking to play locally and one of your machines is reasonably powerful, you can just "Open to LAN" within the game. A paid hosted server is best for those who want to play with a larger number of people outside your home. This could be the official "Realms" or any of several third-party options.