Skip to content

Minecraft 1.19 Server Running on Fabric Loader/Server and Zulu OpenJDK.

License

Notifications You must be signed in to change notification settings

als3bas/docker-fabric-zulu

Repository files navigation

Docker Image Version (latest semver) Docker Image Size (tag) Docker Pulls


Fabric MC Running on Zulu OpenJDK

What is this?

  • This is a docker image that runs a Fabric MC server on Zulu OpenJDK.
  • Fabric is a lightweight, experimental modding toolchain for Minecraft.
  • Zulu OpenJDK is a free, fully compliant, 100% open-source implementation of the Java SE Platform, Standard Edition.

You're free to fork this repo and modify it to your needs.

Why Zulu instead of Temurin, Graalvm, Corretto, etc?

I just wanted to try it, and almost every openjdk implementation are the same. The only problem is that Zulu depends on a single company (Azul), and if they want to change their license or policies, they can do it.

Anyway, I will replicate this repo with Adoptium/Temurin

Requirements

  • Docker 🔎 How to install
  • Docker-compose
  • Preferably Linux, WSL2 or MacOS.
  • Architecture: amd64 or arm64.
  • 4+ GB of RAM (Depending on the players and mods)

Creating a docker-compose.yml file

I prefer to use docker-compose, but you can use the docker cli if you want.

Warning Don't forget to change PUID and PGID envs to run as non-root user.

version: "3.9"

services:
  minecraft:
    container_name: "fabricserver"
    # image: "als3bas/zulu-fabricmc:1.19.3"
    image: "als3bas/zulu-fabricmc:latest"
    # If you want to build the image locally, uncomment this 3 lines and comment the image line above.
    # build: 
    #   context: .
    #   dockerfile: Dockerfile
    restart: unless-stopped
    environment:
      - MEMORYSIZE: "1G"
      - PUID: "xxxx"
      - PGID: "xxxx"
    volumes:
      - ./:/data:rw
    ports:
      - "25565:25565"
    stdin_open: true
    tty: true

Running as non-root user

Set the PUID and PGID environment variables to the user and group id of the user you want to run the server as. To get those values, run the following command:

id $USER
uid=1000(alvaro) gid=984(users) groups=984(users),998(wheel),973(docker)

Then in the docker-compose.yml add the following environment variables:

# docker-compose.yml
# In this example the user is alvaro 1000 and the group is users 984
environment:
  - PUID=1000
  - PGID=984

Update the container

# This command will pull the latest image and restart the container
make update-container

or

# And this is basically the same
docker-compose stop
docker-compose pull
docker-compose up -d

Adding mods

Adding mods is very easy, just copy them to the mods folder and restart the server.

make restart

Running the server

Run

Run the server with the following command:

docker-compose up -d --build

Stop

Stop the server with the following command:

docker-compose stop

Logs

To see the logs of the server, run the following command:

docker-compose logs -f 

Using the makefile

You can use the makefile on this repo

# run the server
make start

# stop the server
make stop

# down the server
make down

# build the server
# useful if you want to update the fabric version
# you won't lose your world, plugins or config files 😉
make build

# restart the server
# useful if you want to update the config or plugin files 
make restart

# attach to the server console
# you can use the server commands like /op /reload, etc
# Remember to use CTRL + P + Q to detach from the console without stopping the server
make attach

# show the last 20 lines of the log
make logs

Common issues

Problems downloading .jar from mojang servers

The make logs will show you something like this:

Downloading mojang_1.xx.xx.jar
mcserver-zulu  | Failed to download mojang_1.xx.xx.jar
mcserver-zulu  | java.net.UnknownHostException: xxxxxxxx.mojang.com

Probably you're using WSL2 and you have problems with the DNS server. You have to modify/create the /etc/docker/daemon.json file and add your favorite dns server.

Example:

sudo nano /etc/docker/daemon.json
{
  "dns": ["1.1.1.1", "8.8.8.8"]
}

References

  • This docker image is based on my repo docker-papermc-graalvm which uses PaperMC & GraalVM as runtime.
  • This repo and the previous one are based on the work of mtoensing