This repository has been archived on 2021-12-24. You can view files and clone it, but cannot push or open issues/pull-requests.
self-hosting/fabric/README.md

82 lines
2.6 KiB
Markdown

# docker-mc-fabric
This repository helps you easily setup a modded Minecraft server using the
[Fabric mod loader](https://fabricmc.net/).
## Installing docker
You can follow the instructions
[here](https://docs.docker.com/engine/install/).
## Building the image
To build the image, you must specify the Fabric version using the `VERSION`
build argument. You can either do this using `docker`:
`docker build -t mc-fabric-server:latest --build-arg VERSION=0.6.1.51 .`
or using `docker-compose`, by specifying the argument in the
`docker-compose.yml` file and running:
`docker-compose build`
See the provided `docker-compose.yml` file for an example of how to specify the
build argument.
## Useful mount points
The container has three useful mount points:
* `/mc/config`: this is where all server config files reside.
* `/mc/config/mods`: this is where all mods should be placed.
* `/mc/worlds`: this is where the world files are stored.
I recommend mounting these to either a local directory or a volume, as to not
lose the server data.
## Environment variables
The container has two environment variables which can be set, namely `XMS` and
`XMX`. If `XMX` is not set, it will use `XMS`'s value by default. Note that
their value is expected to be an integer, which is then used as a quantity for
gigabytes. Therefore, only gigabyte precision is possible.
## Java flags
I use the Java flags defined
[here](https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/).
If you don't agree with this decision, you can change the `ENTRYPOINT` at the
end of the `Dockerfile` to the following:
```
ENTRYPOINT java \
-Xms"${XMS}G" \
-Xmx"${XMX:-$XMS}G" \
-jar fabric-server-launch.jar \
--universe /mc/worlds \
--nogui
```
This will only use the flags absolutely necessary, while still allowing you to
tweak the memory variables.
## Running the server
### docker
You can start the server with the following command:
```
docker run \
--rm \
--interactive \
--tty \
--publish '25565:25565' \
--detach \
mc-fabric-server:latest
```
Or, more compact:
`docker run --rm -dit -p '25565:25565' mc-fabric-server:latest`
This will start the server and run it in the background.
### docker-compose
If you prefer to use `docker-compose` (which I recommend), you can use the
provided `docker-compose.yml` file and edit it to suit your needs. By default,
it creates volumes for the three major mount points, and opens up port `25565`.
Then, you can start the server using `docker-compose up --detach` or
`docker-compose up -d`, because no one likes typing long commands.