A Minecraft server is a box! Starts blank and you fill it with mods. Any architecture. Anywhere.
1.3K
Important
**Do not change the `server-port` in the `server.properties` file.**The Docker container exposes port
25565by default. If you need to use a different port, you must change the port mapping in yourdocker runcommand ordocker-compose.ymlfile.Why? The Docker container is configured to expose the Minecraft server on port
25565. When you run the container, you map a port from your host machine to this internal port. If you change the port inserver.properties, the Minecraft server inside the container will listen on a different port, but the Docker port mapping will still be pointing to the original port (25565), and you won't be able to connect.Correct way to change the port:
If you want to run the server on port
25570on your host machine, change the port mapping in yourdockercommand:# Incorrect # docker run -p 25565:25565 ... (and changing server.properties to 25570) # Correct docker run -p 25570:25565 ...Or in your
docker-compose.yml:# Incorrect # ports: # - "25565:25565" # (and changing server.properties to 25570) # Correct ports: - "25570:25565"
This repository contains the necessary files to build a Docker image for a Minecraft Fabric server.
The Docker image is available on Docker Hub: diareuse/minecraft:fabric
The only dependency is a container runtime that can run Docker images. This includes, but is not limited to:
| Variable | Description | Default |
|---|---|---|
MINECRAFT | The version of Minecraft to install. | |
FABRIC_LOADER | The version of the Fabric loader to use. | |
FABRIC_INSTALLER | The version of the Fabric installer to use. | |
PUID | The user ID to run the Minecraft server as. | 1000 |
PGID | The group ID to run the Minecraft server as. | 1000 |
To avoid permission issues with the data volume (/opt/minecraft), you should run the container
with the user and group ID (PUID and PGID) of your own user.
You can get your current user and group ID by running the following commands in your terminal:
# Get your User ID
id -u
# Get your Group ID
id -g
If you are using Docker Desktop for Windows, the default values of PUID=1000 and PGID=1000 are
generally sufficient and you don't need to change them.
docker rundocker run -d \
-e PUID=$(id -u) \
-e PGID=$(id -g) \
-e MINECRAFT="1.21.10" \
-e FABRIC_LOADER="0.17.3" \
-e FABRIC_INSTALLER="1.1.0" \
-p 25565:25565 \
-v /path/to/your/minecraft/data:/opt/minecraft \
--name minecraft-fabric \
diareuse/minecraft:fabric
docker run -d \
-e PUID=1000 \
-e PGID=1000 \
-e MINECRAFT="1.21.10" \
-e FABRIC_LOADER="0.17.3" \
-e FABRIC_INSTALLER="1.1.0" \
-p 25565:25565 \
-v C:\path\to\your\minecraft\data:/opt/minecraft \
--name minecraft-fabric \
diareuse/minecraft:fabric
docker-composeCreate a docker-compose.yml file. This is the same for all operating systems.
services:
minecraft:
image: diareuse/minecraft:fabric
environment:
- MINECRAFT=${MINECRAFT}
- FABRIC_LOADER=${FABRIC_LOADER}
- FABRIC_INSTALLER=${FABRIC_INSTALLER}
- PUID=${PUID}
- PGID=${PGID}
ports:
- "25565:25565"
volumes:
- ${MINECRAFT_DATA_PATH}:/opt/minecraft
Then create a .env file next to it to configure the variables.
docker-compose with a .env fileThis is the recommended approach.
Create a .env file with the following content. You can get your IDs by running id -u and
id -g.
MINECRAFT_DATA_PATH=/path/to/your/minecraft/data
MINECRAFT=1.21.10
FABRIC_LOADER=0.17.3
FABRIC_INSTALLER=1.1.0
PUID=1000 # Replace with your user ID
PGID=1000 # Replace with your group ID
Create a .env file with the following content:
MINECRAFT_DATA_PATH=C:\path\to\your\minecraft\data
MINECRAFT=1.21.10
FABRIC_LOADER=0.17.3
FABRIC_INSTALLER=1.1.0
PUID=1000
PGID=1000
After creating both docker-compose.yml and .env files, run docker-compose up -d.
This approach allows you to easily configure the path to your Minecraft data without modifying the
docker-compose.yml file.
Content type
Image
Digest
sha256:2e91b3764…
Size
182.8 MB
Last updated
2 months ago
docker pull diareuse/minecraft:fabric-v1.2.0