A lightweight, containerized setup for running a Minecraft Java Edition Server using Docker and Docker Compose.
This repository contains a simple setup for running a Minecraft Java Edition Server inside a Docker container.
It aims to provide a reproducible, portable, and easy-to-deploy environment for hosting your own Minecraft world.
- Dockerfile – builds a custom image based on openjdk:21-jdk-slim
- docker-compose.yaml – defines the mc-server service (ports, environment, volumes)
- entrypoint.sh – startup script that checks the server JAR exists, applies EULA and RAM settings, and starts the server.
- .gitignore – excludes irrelevant files from version control
- .env.example – sample environment configuration
- Docker installed
- Docker Compose installed
- Server JAR is automatically downloaded during the Docker image build using the
SERVER_JAR_URLbuild argument. The entrypoint script only checks if the file exists.
Clone this repository and start the Minecraft server using Docker Compose:
git clone <https://github.com/A-Marbach/minecraft-server>
cd <minecraft-server>
docker-compose up -d --builddocker logs -f mc-serverdocker stop mc-serverEnvironment variables are defined in the docker-compose.yaml. You can change them as needed:
environment:
EULA: "true" # You must accept the Minecraft EULA
MAX_RAM: "2G" # JVM maximum memory allocation
MIN_RAM: "1G" # JVM minimum memory allocation
SERVER_JAR_URL: "https://piston-data.mojang.com/v1/objects/95495a7f485eedd84ce928cef5e223b757d2f764/server.jar" # optional: specific version
# Used as a build argument in Dockerfile. The JAR is downloaded during image build, not by the container.Game data and configuration are stored in a volume so they survive container restarts:
volumes:
- ./data:/opt/minecraftThis ensures:
-
World saves are not lost
-
Configuration persists across rebuilds
The server runs inside the container on port 25565. It is mapped to host port 8888 for external access:
ports:
- "8888:25565"You can connect via Minecraft client using:
<your-server-ip>:8888
.
├── .gitignore
├── docker-compose.yaml
├── Dockerfile
├── entrypoint.sh
└── README.md
- Verify Server Port
You can use nc (netcat) if installed on your system:
nc -zv <your-server-ip> 8888pip install mcstatus
mcstatus <your-server-ip>:8888 status- Confirm Persistence
Restart the container to ensure that world data and configuration persist:
docker restart mc-serverThis project is for educational purposes.
No sensitive information (SSH keys, tokens, IP addresses, etc.) should be committed to the repository.
All configuration is done via environment variables in accordance with best practices.