How To Host A DIY Minecraft Server At Home With Docker

From Mozilla Foundation
Jump to: navigation, search

My oldest son discovered Minecraft recently. My son, on the other hand, 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 together I decided to run an Dockerized Minecraft server on my home server, and it was much simpler than I had expected.



A dedicated server is running



The official server distribution 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 either open the container with the docker run command, or daemonize it. However, I've kept it simple by setting docker compose-up in byobu sessions.



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



There are a variety of configuration options However, I would like to highlight two:



- The game's persistent data is written to a disk that is mounted to the host, so that we can access the files. The "WORLD" option lets you import a save that was created on a different computer.



Connecting to the Server



After a few seconds the server is ready to accept connections, however my clients can't be able to see it due to reasons. Minecraft will sit on the "Scanning for games on your local network" screen for the rest of the time. You can "Add Server" to manually add it, and voila!



Web Map



The majority of my Minecraft knowledge is a decade out of date. Third-party tools can create an online view of a Minecraft environment similar to Google Maps. After doing some research it appears that Minecraft Overviewer is the prominent one these days.



Although the installation process is simple, I came across an Docker file that was even easier to install. This that or the other This is a single-shot (not a persistent) process so we'll use docker run:



Given read-only access to the game data created by the other container, and another volume to write to, this will result in a web map using Leaflet. This directory can be symlinked to a web-served directories on the host, such as the /var/www/public_html directory, which allows ease of access from any web browser.



It takes just a few minutes to run and the results are quite impressive:



Makefile



As per my own wishes, I added some shortcuts to a Makefile for quick access.



The Reasons to Build Dockerized Minecraft Server



A dedicated server built by yourself is probably not needed by the majority of people. If you're looking to play locally with multiplayer and your computer is powerful enough you can click "Open to the LAN" directly from the game. A paid hosted server is more suitable when you would like to play with a greater amount of players from outside your home. This could be the official "Realms" or one of the many third-party alternatives. This that or the other This that or the other