itzg / docker-minecraft-server

Docker image that provides a Minecraft Server that will automatically download selected version at startup
https://docker-minecraft-server.readthedocs.io/
Apache License 2.0
9.23k stars 1.52k forks source link

Include nfs-common package #1842

Closed ThomWilhelm closed 1 year ago

ThomWilhelm commented 1 year ago

Enhancement Type

Improve an existing feature

Describe the enhancement

Firstly, thank you for all your work on these images they are great! This is a bit specific to my setup, but I think it could be a good improvement in allowing these images to work as flexibly as possible.

Recently I've started storing my server data on an NFS share, and then mounting that into the running container. However when I start the server, I've been hitting an intermittent issue which leads to the error java.io.IOException: No locks available

Researching this error I stumbled across some some threads that imply all clients should have the nfs-common package installed: https://github.com/moby/moby/issues/36313 https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-20-04

Looking closer at the nfs-common package: https://packages.debian.org/sid/nfs-common

"Programs included: lockd, statd, showmount, nfsstat, gssd, idmapd and mount.nfs."

So it makes sense to me that file locking on NFS shares may not work without this installed. I extended your container and installed nfs-common, and I've not run in this issue since.

Would you consider including this package in your images? It would provide better NFS support.

[init] Running as uid=1000 gid=1000 with /data as 'drwxrwsr-x 11 1000 1000 4096 Nov 23 19:14 /data'
[init] Resolved version given 1.19.2 into 1.19.2 and major version 1.19
[init] Resolving type given PAPER
[init] Removing old PaperMC versions ...
[init] Downloading PaperMC 1.19.2 (build 282) ...
[init] Disabling whitelist functionality
[init] Setting white-list to 'false' in /data/server.properties
[init] WARNING: whitelist enabled but not enforced. Set ENFORCE_WHITELIST=TRUE or update 'enforce-whitelist' in server.properties to enforce the whitelist.
[init] Setting view-distance to '10' in /data/server.properties
[init] Setting hardcore to 'false' in /data/server.properties
[init] Setting enable-rcon to 'true' in /data/server.properties
[init] Setting rcon.password to 'minecraft' in /data/server.properties
[init] Setting rcon.port to '25575' in /data/server.properties
[init] Setting level-seed to '-4060839488929676108' in /data/server.properties
[init] Setting pvp to 'true' in /data/server.properties
[init] Setting online-mode to 'true' in /data/server.properties
[init] Setting simulation-distance to '10' in /data/server.properties
[init] Setting enforce-secure-profile to 'true' in /data/server.properties
[init] Setting motd to 'A free Minecraft Server' in /data/server.properties
[init] Setting difficulty to 'easy' in /data/server.properties
[init] Setting mode
[init] Setting gamemode to 'survival' in /data/server.properties
[init] Updating ops
[init] Checking for JSON files.
[init] Setting initial memory to 1664M and max to 1664M
[init] Starting the Minecraft server...
Downloading mojang_1.19.2.jar
Applying patches
Starting org.bukkit.craftbukkit.Main
System Info: Java 17 (Eclipse OpenJ9 VM openj9-0.32.0) Host: Linux 5.10.0-0.bpo.15-amd64 (amd64)
Loading libraries, please wait...
2022-11-23 19:15:12,307 ServerMain WARN Advanced terminal features are not available in this environment
[19:15:15 INFO]: Building unoptimized datafixer
[19:15:16 INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[19:15:19 ERROR]: Failed to start the minecraft server
java.io.IOException: No locks available
    at sun.nio.ch.FileDispatcherImpl.lock0(Native Method) ~[?:?]
    at sun.nio.ch.FileDispatcherImpl.lock(Unknown Source) ~[?:?]
    at sun.nio.ch.FileChannelImpl.tryLock(Unknown Source) ~[?:?]
    at java.nio.channels.FileChannel.tryLock(Unknown Source) ~[?:?]
    at net.minecraft.util.DirectoryLock.create(DirectoryLock.java:31) ~[?:?]
    at net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess.<init>(LevelStorageSource.java:398) ~[?:?]
    at net.minecraft.world.level.storage.LevelStorageSource.createAccess(LevelStorageSource.java:323) ~[?:?]
    at net.minecraft.server.Main.main(Main.java:185) ~[paper-1.19.2.jar:git-Paper-282]
    at org.bukkit.craftbukkit.Main.main(Main.java:302) ~[paper-1.19.2.jar:git-Paper-282]
    at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42) ~[app:?]
    at java.lang.Thread.run(Unknown Source) ~[?:?]
2022-11-23T19:15:19.740Z    INFO    mc-server-runner    Done
itzg commented 1 year ago

I don't mind adding it, but am a little unsure how adding that within the container makes a difference. Containers mount in the filesystem from the host and use the same kernel as the host, so installation at the host level makes more sense to me.

You can PR that if you want.

ThomWilhelm commented 1 year ago

I think from your comment I understand why this is happening further now.

I'm running this on a cloud based Kubernetes platform. I'm deploying the NFS storage and Minecraft server as 2 separate deployments, so I'm guessing the host node itself (which I have no control over) doesn't have these NFS utilities installed.

Therefore I think the only way around this is installing into the container itself, which would explain why it's fixed the issue for me. So I believe the PR I've submitted would fix cases the host kernel doesn't have these NFS utilities installed.

itzg commented 1 year ago

That makes sense.