Do you want to host your own Minecraft Server on Docker with Mods?
Looking for a Forge or Fabric Minecraft Server on Docker?
Look at itzg’s Minecraft Server for Docker: GitHub, DockerHub.
You will need a Minecraft Java Version installed on your device.
As well as a Forge installation.
1. Hosting a Minecraft Server on Docker
You need Traefik set up!
Create a new Directory and cd into it.
mkdir minecraft && cd minecraft
As always make sure, you have an A record pointed at the Server.
In there we’ll have to set up the docker-compose.yml.
nano docker-compose.yml
Paste this: (For newcomers: This is a Traefik setup, if you haven’t set Traefik up, take a look at this Post)
Replace your-domain.com with your domain.
If you want to use more environment variables, take a look at this.
version: '3' services: minecraft-server: image: "itzg/minecraft-server" container_name: "minecraftserver" volumes: - "./data:/data" - "./plugins:/plugins" environment: EULA: "TRUE" TYPE: "FORGE" VERSION: "1.16.4" FORGE_INSTALLER: installer.jar tty: true stdin_open: true restart: always ports: - 25565:25565 labels: - "traefik.enable=true" - "traefik.http.routers.mc-web.rule=Host(`mc.your-domain.com`)" - "traefik.http.routers.mc-web.entrypoints=web" - "traefik.http.routers.mc-web.middlewares=redirect@file" - "traefik.http.routers.mc-secured.rule=Host(`mc.your-domain.com`)" - "traefik.http.routers.mc-secured.entrypoints=web-secured" - "traefik.http.routers.mc-secured.tls.certresolver=mytlschallenge" networks: web: external: true backend: external: false
Now you’ll have to download the Forge Installer file:
sudo curl http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.16.4-35.1.13/forge-1.16.4-35.1.13-installer.jar -o data/installer.jar
And then spin up the Stack.
docker-compose up -d
You’ll have to wait a few minutes. You can look at the progress in Portainer.
To connect to your server, just join mc.your-domain.com in Minecraft.
2. Add mods
To add mods we just have to download them and put them into the data/mods folder.
I’m going to download mods from CurseForge. In this example I’ll be using the JustEnoughItems Mod.
curl https://www.curseforge.com/minecraft/mc-mods/jei/download/3071356 -o data/mods/jei.jar
Technically you can just curl any mod from the internet, however I couldn’t find the .jar link anywhere, so I’ll instead download the files to my computer, which I have to do anyway, and then upload them via FTP. Want to know how to install FTP? Click here.
Every Client who wants to play needs the same Mods, with the same version.
To figure out what Mods you are running, join any server and type in the command:
/forge mods
And it’ll give you a list of all the mods.
I haven’t found a command to figure out what Mods the server is running, they’ll have to ask you, the admin.
3. Errors
3.1 Can’t find the Server.jar
If you get an Error saying it can’t find the Server jar, you’ll have to download it manually.
First stop the Stack:
docker-compose down
Now download the Server:
sudo curl https://launcher.mojang.com/v1/objects/35139deedbd5182953cf1caa23835da59ca3d7cd/server.jar -o data/minecraft_server.1.16.4.jar
Now spin up the Stack again, and it should work:
docker-compose up -d