How To Host A DIY Minecraft Server At Home Using Docker

From MotoGP
Jump to: navigation, search

My oldest child discovered Minecraft recently. While a lot of his friends play Bedrock Edition on an iPad or game console, my son plays the old-fashioned Java Edition on an old computer. (And he can launch it via the terminal! ) To play with each other, I looked into running a Dockerized Minecraft server on my home server and it was easier than I expected.



Operating a dedicated server



The official server distribution is only a single Java jar, so it should be fairly simple 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. I prefer to keep it simple and run docker compose up in my byobu session.



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



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



- Game's persistent data are written to a volume mounted on the host. This lets us easily access the files. The "WORLD" option is handy for importing an existing save created on a different computer.



Connecting to the Server



The server will allow connections in a few seconds. However my clients aren't in a position to see it. Minecraft will remain on the "Scanning games on your local network screen" screen for the rest of time. Best minecraft servers No matter the reason, you can "Add Server" to add it manually, 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 the one in Google Maps. After a bit of research it appears that Minecraft Overviewer is the prominent one of the moment.



Although the installation of this tool is easy, I discovered a Docker file that was more simple. This is a single-shot (not an ongoing) process so we'll use docker 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 can be linked to a web-served directory on the host, for example the directory /var/www/public_html for easy access from any internet browser.



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



Makefile



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



Reasons You Might Want to build a Dockerized Minecraft Server



A dedicated server built by yourself is probably not needed by the majority of people. If you're just looking for a way to play multiplayer locally and one of your computers is reasonably powerful, you can simply "Open to LAN" from inside the game. If you're looking to play with a larger number of folks outside your household it's best to go using a hosted server that is paid for. This could be the official "Realms" or one of the many third-party options.