This repository serves as a guide for containerizing a simple Minecraft Server: Java Edition using Docker Compose.
This Repository was created as part of my training at the Developer Academy.
- Docker 24.0.7
- Compose v2.32.4 (module to install, More Information)
- Minecraft Server Java Edition 1.21.4 (server to download, More Information)
Minecraft is a popular sandbox game that allows players to explore, build, and adventure in their own worlds. Alone or in multiplayer mode.
A Minecraft Server is a program that allows players to play Minecraft online in a multiplayer environment. A server hosts these worlds and allows multiple players to connect and play together at the same time. A Minecraft Server typically runs on a dedicated computer or virtual machine and can be operated in various configurations. Players connect to the server via its IP address and port.
If you want to use mods and/or plugins, there are something to keep in mind:
-
Standard Minecraft Server software (vanilla) - that is used here - does not support mods, only the basic functions of the game.
- You can customize the game a little using data packs and configuration files (like server.properties) (e.g. the number of players allowed, etc.)
-
To use mods and/or plugins you must use an advanced server:
There is the Java Edition and the Bedrock Edition of Minecraft - two different versions of the game that differ in technology, features and compatibility.
This repository containerizes the Java Edition Server:
- only suitable for the PC
- runs via the Java Runtime Environment (JRE)
- easy to set up
- saves resources
Tip
If you are interested in a cross-platform application, for example because you want to play Minecraft on a console, you need the Bedrock Server.
This section provides a fast and minimal setup guide for using the tools in this repository. For a more in-depth understanding and additional options, please refer to the Usage section.
-
Clone the project to your platform if you just want to use it:
- Example: Clone the repo e.g. using an SSH-Key:
git clone git@github.com:MarcelDechant/minecraft_server.git
-
Navigate into the project directory Change into the cloned project directory:
cd minecraft_server -
Download the Java Server file from the Minecraft webpage. For copyright reasons, the server file will not be uploaded to github.:
https://www.minecraft.net/de-de/download/server
-
Make the file executable if necessary:
chmod +x server.jar
-
Create your
.envfile from the provided template:
This file contains configuration values for your Minecraft server such as player limits, seed, and view distance.cp example.env .env
You can edit the file using a text editor:
nano .env
Example contents:
MAX_PLAYERS=10 LEVEL_SEED=4025804172371830787 VIEW_DISTANCE=10
-
Build and start the container in the background (detached mode):
docker compose up --build -d
-
Check whether the server is running correctly:
-
If you have a Minecraft account: You can connect to the server on your cloud VM from your Java Minecraft client on your computer and play Minecraft.
-
If you don’t have a Minecraft account, you can check whether the server is online using this tool: use a website that shows the status of Minecraft servers or try to establish a connection to the Minecraft server using the Python
mcstatusmodule.
Note
The Minecraft server can be reached under the IP address of your cloud VM on port 8888: http://IP_Address_VM:8888
-
Clone the project to your platform:
- Example: Clone the repo e.g. using an SSH-Key:
git clone git@github.com:MarcelDechant/minecraft_server.git
-
Download the Java Server file from the Minecraft webpage. For copyright reasons, the server file will not be uploaded to github.:
https://www.minecraft.net/de-de/download/server
- Don't forget to move the server file to the project folder, e.g. from Windows PC to a VM via SSH:
- scp /path/to/minecraft_server/server.jar username@vm-ip:/path/to/minecraft_server
- Don't forget to move the server file to the project folder, e.g. from Windows PC to a VM via SSH:
-
It may be that the server file needs to be made executable:
- View rights of the files in the directory:
ls -l
-
For the
server.jarfile it should look like this:- -rwxr-xr-x
-
Set execute permissions if they don't exist:
chmod +x server.jar
-
Create the environment configuration file:
Use the includedexample.envto create your.envfile.cp example.env .env
Edit the file to adjust values as needed (you can use
nano,vim, etc.):MAX_PLAYERS=10 LEVEL_SEED=4025804172371830787 VIEW_DISTANCE=10
-
The
Dockerfiledescribes how a single Docker image should be created. It serves as the basis for a service in the Docker Compose file. -
The
compose.yamlis responsible for managing and orchestrating the Minecraft Server container. It defines what configurations it should have. -
The
server.propertiesfile plays a central role in setting up a Minecraft Java server. It contains the configuration options that allow you to customize the behavior of the server, the game rules and the technical characteristics. -
Build and start the container in the background (detached mode):
docker compose up --build -d
-
To view the log files:
docker compose logs -f
-
To stop the container:
docker compose stop <container-name>
-
To delete the container:
docker compose down <container-name>
-
To list all containers that are operatet by Docker Compose:
docker compose ps
-
-
Check whether the server is running correctly:
-
If you have a Minecraft account: You can connect to the server on your cloud VM from your Java Minecraft client on your computer and play Minecraft.
-
Use a website that offers status checks for Minecraft Servers or try to establish a connection to the Minecraft Server using the python
mcstatusmodule.
Note
The Minecraft server can be reached under the IP address of your cloud VM on port 8888: http://IP_Address_VM:8888.
The ERR_EMPTY_RESPONSE error message means that the browser tried to communicate with the server but did not receive any data. This is to be expected since a Minecraft Server doesn't send HTTP data that a browser can interpret. The Minecraft server uses Minecraft's own protocol, which is not compatible with a web browser.The Minecraft Server is running correctly and listening on the specified port (e.g. 8888), but it only responds to requests from Minecraft clients, not HTTP requests.

Alternative:
You can work with the Docker Minecraft Server that uses the base image itzg/minecraft-server. This image already containes the server file and the java environment.
The Minecraft Wiki offers a setup for this but points out that the contents of this setup are not supported by Mojang Studios or the Minecraft Wiki.
