This guide explains how to build and deploy your Minecraft Fabric mod using Docker.
- Docker installed on your system
- Java 21 for building the mod
- Fabric server launcher jar file
Download both the Fabric server launcher and Fabric API for Minecraft 1.21.7:
# Use the provided download script (downloads both files)
./download-fabric-server.sh
# Or download manually:
# Fabric Server Launcher
wget https://meta.fabricmc.net/v2/versions/loader/1.21.7/0.16.14/1.0.3/server/jar -O fabric-server-launch.jar
# Fabric API (create mods directory first)
mkdir -p mods
wget "https://cdn.modrinth.com/data/P7dR8mSH/versions/VjIVvVhW/fabric-api-0.128.1%2B1.21.7.jar" -O mods/fabric-api-0.128.1+1.21.7.jarcp eula.txt.example eula.txt
# Edit eula.txt and set eula=truecp server.properties.example server.properties
# Edit server.properties as needed# Build the mod jar
./gradlew build
# Build Docker image using Gradle tasks
./gradlew dockerBuild
# Build and run Docker container
./gradlew dockerRun
# Push to registry (if configured)
./gradlew dockerPush# Build image
docker build -f minecraft.Dockerfile -t minecraft-fabric-mod .
# Run container
docker run -d -p 25565:25565 -p 7070:7070 -v minecraft_data:/minecraft minecraft-fabric-mod# Start the server with persistent volumes
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the server
docker-compose down
# Stop and remove volumes (WARNING: This deletes world data)
docker-compose down -v./gradlew dockerBuild- Build Docker image./gradlew dockerRun- Build and run container (stops existing first)./gradlew dockerStop- Stop and remove running container./gradlew dockerLogs- View container logs./gradlew dockerPush- Push image to registry./gradlew dockerCompose- Start services using docker-compose
- 25565: Minecraft server port
- 7070: API server port for mod endpoints
/minecraft- Full server home (persistent)
The container now keeps packaged binaries and default config templates inside the image under /opt/minecraft-dist, then syncs them into the live /minecraft volume on startup. Runtime state such as ops.json, whitelist.json, banned-players.json, banned-ips.json, world data, and logs persists across container recreation.
On startup, the container:
- refreshes the server launcher and packaged mod jars from the image
- creates
server.propertiesandeula.txtonly if they do not already exist in the volume - preserves operator-managed files already present in
/minecraft
Once running, the mod API will be available at:
http://localhost:7070/api/world/playershttp://localhost:7070/api/world/entitieshttp://localhost:7070/api/world/blocks/*http://localhost:7070/api/message/*
- Check EULA acceptance in
eula.txt - Verify Fabric server jar is present
- Check Docker logs:
docker-compose logs minecraft
- Check if port 7070 is exposed
- Verify mod is loaded correctly
- Check server logs for errors
- Adjust JAVA_OPTS in docker-compose.yml
- Increase Docker memory limits
- Monitor with
docker stats
For development, you can mount your mod directly:
# Add to docker-compose.yml volumes:
- ./build/libs:/opt/minecraft-dist/modsThen rebuild your mod and restart the container to test changes.